Friday, April 3, 2026
HomeLanguagesPython | Numpy np.poly2leg() method

Python | Numpy np.poly2leg() method

With the help of np.poly2leg() method, we can get the Legendre series coefficient from a given polynomial.

Syntax : np.poly2leg(polynomial)
Return : Return the coefficient of Legendre series.

Example #1 :
In this example we can see that by using np.poly2leg() method, we are able to get the coefficients of Legendre series from polynomial using this method.




# import numpy and poly2leg
import numpy as np
from numpy.polynomial.legendre import poly2leg
  
arr = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
# using np.poly2leg() method
ans = poly2leg(arr)
  
print(ans)


Output :

[ 0.3 0.44 0.48571429 0.16 0.11428571]

Example #2 :




# import numpy and poly2leg
import numpy as np
from numpy.polynomial.legendre import poly2leg
  
arr = np.array([-0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5])
# using np.poly2leg() method
ans = poly2leg(arr)
  
print(ans)


Output :

[-0.52692641 -0.34424242 0.08651349 0.16149184 0.27684316 0.13948718
0.13127578 0.03905114 0.02952276 0.00421226 0.00277122]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32512 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6886 POSTS0 COMMENTS
Nicole Veronica
12007 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12100 POSTS0 COMMENTS
Shaida Kate Naidoo
7015 POSTS0 COMMENTS
Ted Musemwa
7259 POSTS0 COMMENTS
Thapelo Manthata
6972 POSTS0 COMMENTS
Umr Jansen
6960 POSTS0 COMMENTS