NumPy

Previous topic

numpy.polynomial.legendre.leg2poly

Next topic

Laguerre Module (numpy.polynomial.laguerre)

numpy.polynomial.legendre.poly2leg

numpy.polynomial.legendre.poly2leg(pol)[source]

Convert a polynomial to a Legendre series.

Convert an array representing the coefficients of a polynomial (relative to the “standard” basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Legendre series, ordered from lowest to highest degree.

Parameters
polarray_like

1-D array containing the polynomial coefficients

Returns
cndarray

1-D array containing the coefficients of the equivalent Legendre series.

See also

leg2poly

Notes

The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance.

Examples

>>> from numpy import polynomial as P
>>> p = P.Polynomial(np.arange(4))
>>> p
Polynomial([0.,  1.,  2.,  3.], domain=[-1,  1], window=[-1,  1])
>>> c = P.Legendre(P.legendre.poly2leg(p.coef))
>>> c
Legendre([ 1.  ,  3.25,  1.  ,  0.75], domain=[-1,  1], window=[-1,  1]) # may vary