Python | Numpy np.leg2poly() method (original) (raw)

Last Updated : 29 Dec, 2019

**np.leg2poly()** method is used to convert a legendre series to a polynomial.

Syntax : np.leg2poly(c)
Parameters:
**c :**[array_like] 1-D arrays of legendre series coefficients ordered from low to high.

Return : [ndarray] 1-D array containing the coefficients of the equivalent polynomial.

Code #1 :

import numpy as np

import numpy.polynomial.legendre as geek

c = np.array([ 0.1 , 0.2 , 0.3 , 0.4 , 0.5 ])

res = geek.leg2poly(c)

print (res)

Output:

[ 0.1375 -0.4 -1.425 1. 2.1875]

Code #2 :

import numpy as np

import numpy.polynomial.legendre as geek

c = ( 1 , 2 , 3 , 4 , 5 )

res = geek.leg2poly(c)

print (res)

Output:

[ 1.375 -4. -14.25 10. 21.875]

Similar Reads