Friday, September 27, 2024
Google search engine
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 Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments