
maprat - execute a function on general expressions

Calling sequence:

maprat(e, f [ ,p ])
rationalize(e [ ,p ])

Parameters:
e  --   expression
f  --   function
p  --   procedure

Summary:

maprat(e, f, p) first replaces in e all subexpressions for which p does not
return TRUE, and which are not constants or variables, by new variables ;
then it calls the function f on this new expression, and substitutes back
those sub-expressions.  If p is not given, a default procedure is used, that
replaces all non-rational subexpressions, that is expressions that are neither
a sum nor a product nor a power with an integer exponent.

The call rationalize(e, p) returns an expression sequence containing the
intermediate expression used in maprat, and a list of substitutions.

>>  factor(sin(1)^2-1);

     Error: not a polynomial [factor]

>>  maprat(sin(1)^2-1,factor);

                 [1, sin(1) - 1, 1, sin(1) + 1, 1]

>>  e:=x^3+2*sqrt(3):
    rationalize(e);

                            3  {      1/2 }
                     2 X2 + x , { X2 = 3    }

>>  rationalize(e,func(contains({"_plus","_mult"},type(x)),x));

                          {      3       1/2 }
                 X3 + 2 X4, { X3 = x , X4 = 3    }

See also:  genident

