Python | Numpy np.legcompanion() method
Last Updated :
31 Dec, 2019
np.legcompanion()
method is used to return the companion matrix of legendre series.
Syntax : np.legcompanion(c)
Parameters:
c :[array_like] 1-D arrays of legendre series coefficients ordered from low to high.
Return : [ndarray] Companion matrix of dimensions (deg, deg).
Code #1 :
import numpy as np
import numpy.polynomial.legendre as geek
s = ( 2 , 4 , 8 )
res = geek.legcompanion(s)
print (res)
|
Output:
[[ 0. 0.28867513]
[ 0.57735027 -0.33333333]]
Code #2 :
import numpy as np
import numpy.polynomial.legendre as geek
s = ( 1 , 2 , 3 , 4 , 5 )
res = geek.legcompanion(s)
print (res)
|
Output:
[[ 0. 0.57735027 0. -0.30237158]
[ 0.57735027 0. 0.51639778 -0.34914862]
[ 0. 0.51639778 0. 0.10141851]
[ 0. 0. 0.50709255 -0.45714286]]
Share your thoughts in the comments
Please Login to comment...