Maxima Function
let (prod, repl, predname, arg_1, ..., arg_n)
let([prod,repl,predname,arg_1,...,arg_n],package_name)
Defines a substitution rule for letsimp such that prod is replaced by repl.
prod is a product of positive or negative powers of the following terms:
Atoms which letsimp will search for literally unless previous
to calling letsimp the matchdeclare function is used to associate a
predicate with the atom. In this case letsimp will match the atom to
any term of a product satisfying the predicate.
Kernels such as sin(x), n!, f(x,y), etc. As with atoms above
letsimp will look for a literal match unless matchdeclare is used to
associate a predicate with the argument of the kernel.
A term to a positive power will only match a term having at least that
power. A term to a negative power
on the other hand will only match a term with a power at least as
negative. In the case of negative powers in prod the switch
letrat must be set to true.
See also .
If a predicate is included in the let function followed by a list of
arguments, a tentative match (i.e. one that would be accepted if the
predicate were omitted) is accepted only if
predname (arg_1', ..., arg_n') evaluates to true where arg_i' is the value
matched to arg_i. The arg_i may be the name of any atom or the argument
of any kernel appearing in prod.
repl may be any rational expression.
If any of the atoms or arguments from prod appear in repl the
appropriate substitutions are made.
The global flag letrat controls the simplification of quotients by letsimp.
When letrat is false,
letsimp simplifies the numerator and
denominator of expr separately, and does not simplify the quotient.
Substitutions such as n!/n goes to (n-1)! then fail.
When letrat is true, then the numerator,
denominator, and the quotient are simplified in that order.
These substitution functions allow you to work with several rule packages at once.
Each rule package can contain any number of let
rules and is referenced by a user-defined name.
let ([prod, repl, predname, arg_1, ..., arg_n], package_name)
adds the rule predname to the rule package package_name.
letsimp (expr, package_name)
applies the rules in package_name.
letsimp (expr, package_name1, package_name2, ...)
is equivalent to letsimp (expr, package_name1)
followed by letsimp (%, package_name2), ....
current_let_rule_package is the name of the rule package that is
presently being used.
This variable may be assigned the name of
any rule package defined via the let command.
Whenever any of the functions comprising the let package are called with no package name,
the package named by current_let_rule_package is used.
If a call such as letsimp (expr, rule_pkg_name) is made,
the rule package rule_pkg_name is used for that letsimp command only,
and current_let_rule_package is not changed.
If not otherwise specified,
current_let_rule_package defaults to default_let_rule_package.
(%i1) matchdeclare ([a, a1, a2], true)$ (%i2) oneless (x, y) := is (x = y-1)$ (%i3) let (a1*a2!, a1!, oneless, a2, a1); (%o3) a1 a2! --> a1! where oneless(a2, a1) (%i4) letrat: true$ (%i5) let (a1!/a1, (a1-1)!); a1! (%o5) --- --> (a1 - 1)! a1 (%i6) letsimp (n*m!*(n-1)!/m); (%o6) (m - 1)! n! (%i7) let (sin(a)^2, 1 - cos(a)^2); 2 2 (%o7) sin (a) --> 1 - cos (a) (%i8) letsimp (sin(x)^4); 4 2 (%o8) cos (x) - 2 cos (x) + 1