
mapcoeffs  -  applies  a  function  to  the  coefficients  of  a

polynomial

Calling sequence:

mapcoeffs(poly, proc [ , expr_2 ... ])
mapcoeffs(expr [ , indets ], proc [ , expr_2 ... ])
indets  ---> [ expr_1 ...]

Parameter:
poly                    --  polynomial
proc                    --  procedure or function
expr, expr_1, expr_2    --  expressions

Overloading:

1

Summary:

mapcoeffs maps a function to the coefficients of a polynomial and then
returns the polynomial with the new coefficients.

 o  With a call of the form mapcoeffs(p,f), f(ci) is executed for each
    coefficient ci of the polynomial p.

  o  With a call of the form mapcoeffs(p,f,a1,...,an), f(ci,a1,...,an)
     is executed for each ci with the additional parameters a1,...,an.

The first argument of mapcoeffs is allowed to be a polynomial or an expression
and optionally a listof indeterminates.  An expression is converted into a
polynomial in the specified indeterminates (see function poly). mapcoeffs
returns FAIL if the expression cannot be converted into a polynomial. The
result is of the same type as the first argument, e.g. if the argument is
a polynomial then the result is a polynomial too. mapcoeffs is a kernel
function.

>>  mapcoeffs(3*x^3+x^2*y^2+2, sin);

      sin(3)*x^3+sin(1)*x^2*y^2+sin(2)

>>  mapcoeffs(3*x^3+x^2*y^2+2, _plus, 2, a);

      (a+5)*x^3+(a+3)*x^2*y^2+a+4

>>  p := poly(x^3+2):
    f := proc(a,b) begin exp(a+b) end_proc:
    mapcoeffs(p, f, 2);

      poly(exp(3)*x^3 + exp(4), [x])

See also:  coeff , lcoeff , map, nterms , nthcoeff , poly, tcoeff

