numpy.polynomial.polynomial.polyint

numpy.polynomial.polynomial.polyint(cs, m=1, k=[], lbnd=0, scl=1)

Integrate a polynomial.

Returns the polynomial cs, integrated m times from lbnd to x. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable. (“Buyer beware”: note that, depending on what one is doing, one may want scl to be the reciprocal of what one might expect; for more information, see the Notes section below.) The argument cs is a sequence of coefficients, from lowest order term to highest, e.g., [1,2,3] represents the polynomial 1 + 2*x + 3*x**2.

Parameters :

cs : array_like

1-d array of polynomial coefficients, ordered from low to high.

m : int, optional

Order of integration, must be positive. (Default: 1)

k : {[], list, scalar}, optional

Integration constant(s). The value of the first integral at zero is the first value in the list, the value of the second integral at zero is the second value, etc. If k == [] (the default), all constants are set to zero. If m == 1, a single scalar can be given instead of a list.

lbnd : scalar, optional

The lower bound of the integral. (Default: 0)

scl : scalar, optional

Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1)

Returns :

S : ndarray

Coefficients of the integral.

Raises :

ValueError :

If m < 1, len(k) > m.

See also

polyder

Notes

Note that the result of each integration is multiplied by scl. Why is this important to note? Say one is making a linear change of variable u = ax + b in an integral relative to x. Then dx = du/a, so one will need to set scl equal to 1/a - perhaps not what one would have first thought.

Examples

>>> from numpy import polynomial as P
>>> cs = (1,2,3)
>>> P.polyint(cs) # should return array([0, 1, 1, 1])
array([ 0.,  1.,  1.,  1.])
>>> P.polyint(cs,3) # should return array([0, 0, 0, 1/6, 1/12, 1/20])
array([ 0.        ,  0.        ,  0.        ,  0.16666667,  0.08333333,
        0.05      ])
>>> P.polyint(cs,k=3) # should return array([3, 1, 1, 1])
array([ 3.,  1.,  1.,  1.])
>>> P.polyint(cs,lbnd=-2) # should return array([6, 1, 1, 1])
array([ 6.,  1.,  1.,  1.])
>>> P.polyint(cs,scl=-2) # should return array([0, -2, -2, -2])
array([ 0., -2., -2., -2.])

Previous topic

numpy.polynomial.polynomial.polyder

Next topic

numpy.polynomial.polynomial.polyadd

This Page