Maxima Function
scanmap (f, expr)
scanmap(f,expr,bottomup)
Recursively applies f to expr, in a top down manner. This is most useful when complete factorization is desired, for example:
Note the way in which scanmap
applies the given function
factor
to the constituent subexpressions of expr; if
another form of expr is presented to scanmap
then the
result may be different. Thus, %o2
is not recovered when
scanmap
is applied to the expanded form of exp
:
Here is another example of the way in which scanmap
recursively
applies a given function to all subexpressions, including exponents:
(%i4) expr : u*v^(a*x+b) + c$ (%i5) scanmap('f, expr); f(f(f(a) f(x)) + f(b)) (%o5) f(f(f(u) f(f(v) )) + f(c))
scanmap (f, expr, bottomup)
applies f to expr in a
bottom-up manner. E.g., for undefined f
,
scanmap(f,a*x+b) -> f(a*x+b) -> f(f(a*x)+f(b)) -> f(f(f(a)*f(x))+f(b)) scanmap(f,a*x+b,bottomup) -> f(a)*f(x)+f(b) -> f(f(a)*f(x))+f(b) -> f(f(f(a)*f(x))+f(b))
In this case, you get the same answer both ways.