Maxima Function
fullratsubst (a, b, c)
is the same as ratsubst
except that it calls
itself recursively on its result until that result stops changing.
This function is useful when the replacement expression and the
replaced expression have one or more variables in common.
fullratsubst
will also accept its arguments in the format of
lratsubst
. That is, the first argument may be a single substitution
equation or a list of such equations, while the second argument is the
expression being processed.
load ("lrats")
loads fullratsubst
and lratsubst
.
Examples:
(%i1) load ("lrats")$
subst
can carry out multiple substitutions.
lratsubst
is analogous to subst
.
(%i2) subst ([a = b, c = d], a + c); (%o2) d + b (%i3) lratsubst ([a^2 = b, c^2 = d], (a + e)*c*(a + c)); (%o3) (d + a c) e + a d + b c
If only one substitution is desired, then a single equation may be given as first argument.
(%i4) lratsubst (a^2 = b, a^3); (%o4) a b
fullratsubst
is equivalent to ratsubst
except that it recurses until its result stops changing.
(%i5) ratsubst (b*a, a^2, a^3); 2 (%o5) a b (%i6) fullratsubst (b*a, a^2, a^3); 2 (%o6) a b
fullratsubst
also accepts a list of equations or a single
equation as first argument.
(%i7) fullratsubst ([a^2 = b, b^2 = c, c^2 = a], a^3*b*c); (%o7) b (%i8) fullratsubst (a^2 = b*a, a^3); 2 (%o8) a b
fullratsubst
may cause an indefinite recursion.
(%i9) errcatch (fullratsubst (b*a^2, a^2, a^3)); *** - Lisp stack overflow. RESET