### The Maxima on-line user's manual

Algebra Calculator

#### Scanmap

Function: scanmap (<f>, <expr>)

Function: 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:

(%i1) exp:(a^2+2*a+1)*y + x^2\$
(%i2) scanmap(factor,exp);
2      2
(%o2)                         (a + 1)  y + x

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:

(%i3) scanmap(factor,expand(exp));
2                  2
(%o3)                      a  y + 2 a y + y + x

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.

(%o1)                                true
(%i2)

? scanmap;

Calculate

? scanmap;

Calculate