Open In App

Python | Numpy np.legvander3d() method

Improve
Improve
Like Article
Like
Save
Share
Report

np.legvander3d() method is used to returns the Vandermonde matrix of degree deg and sample points x, y and z.

Syntax : np.legvander3d(x, y, z, deg)
Parameters:
x, y, z :[ array_like ] Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array.
deg :[int] Degree of the resulting matrix.

Return : Return the Vandermonde matrix.

Example #1 :
In this example we can see that by using np.legvander3d() method, we are able to get the pseudo-vandermonde matrix using this method.




# import numpy
import numpy as np
import numpy.polynomial.legendre as geek
  
# using np.legvander3d() method
ans = geek.legvander3d((1, 3, 5), (2, 4, 6), (1, 2, 3), [2, 2, 2])
  
print(ans)


Output :

[[ 1.00000000e+00 1.00000000e+00 1.00000000e+00 2.00000000e+00
2.00000000e+00 2.00000000e+00 5.50000000e+00 5.50000000e+00
5.50000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00
2.00000000e+00 2.00000000e+00 2.00000000e+00 5.50000000e+00
5.50000000e+00 5.50000000e+00 1.00000000e+00 1.00000000e+00
1.00000000e+00 2.00000000e+00 2.00000000e+00 2.00000000e+00
5.50000000e+00 5.50000000e+00 5.50000000e+00]
[ 1.00000000e+00 2.00000000e+00 5.50000000e+00 4.00000000e+00
8.00000000e+00 2.20000000e+01 2.35000000e+01 4.70000000e+01
1.29250000e+02 3.00000000e+00 6.00000000e+00 1.65000000e+01
1.20000000e+01 2.40000000e+01 6.60000000e+01 7.05000000e+01
1.41000000e+02 3.87750000e+02 1.30000000e+01 2.60000000e+01
7.15000000e+01 5.20000000e+01 1.04000000e+02 2.86000000e+02
3.05500000e+02 6.11000000e+02 1.68025000e+03]
[ 1.00000000e+00 3.00000000e+00 1.30000000e+01 6.00000000e+00
1.80000000e+01 7.80000000e+01 5.35000000e+01 1.60500000e+02
6.95500000e+02 5.00000000e+00 1.50000000e+01 6.50000000e+01
3.00000000e+01 9.00000000e+01 3.90000000e+02 2.67500000e+02
8.02500000e+02 3.47750000e+03 3.70000000e+01 1.11000000e+02
4.81000000e+02 2.22000000e+02 6.66000000e+02 2.88600000e+03
1.97950000e+03 5.93850000e+03 2.57335000e+04]]

Example #2 :




# import numpy
import numpy as np
import numpy.polynomial.legendre as geek
  
ans = geek.legvander3d((1, 2), (3, 4), (5, 6), [3, 3, 3])
  
print(ans)


Output :

[[ 1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
3.00000000e+00 1.50000000e+01 1.11000000e+02 9.15000000e+02
1.30000000e+01 6.50000000e+01 4.81000000e+02 3.96500000e+03
6.30000000e+01 3.15000000e+02 2.33100000e+03 1.92150000e+04
1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
3.00000000e+00 1.50000000e+01 1.11000000e+02 9.15000000e+02
1.30000000e+01 6.50000000e+01 4.81000000e+02 3.96500000e+03
6.30000000e+01 3.15000000e+02 2.33100000e+03 1.92150000e+04
1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
3.00000000e+00 1.50000000e+01 1.11000000e+02 9.15000000e+02
1.30000000e+01 6.50000000e+01 4.81000000e+02 3.96500000e+03
6.30000000e+01 3.15000000e+02 2.33100000e+03 1.92150000e+04
1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
3.00000000e+00 1.50000000e+01 1.11000000e+02 9.15000000e+02
1.30000000e+01 6.50000000e+01 4.81000000e+02 3.96500000e+03
6.30000000e+01 3.15000000e+02 2.33100000e+03 1.92150000e+04]
[ 1.00000000e+00 6.00000000e+00 5.35000000e+01 5.31000000e+02
4.00000000e+00 2.40000000e+01 2.14000000e+02 2.12400000e+03
2.35000000e+01 1.41000000e+02 1.25725000e+03 1.24785000e+04
1.54000000e+02 9.24000000e+02 8.23900000e+03 8.17740000e+04
2.00000000e+00 1.20000000e+01 1.07000000e+02 1.06200000e+03
8.00000000e+00 4.80000000e+01 4.28000000e+02 4.24800000e+03
4.70000000e+01 2.82000000e+02 2.51450000e+03 2.49570000e+04
3.08000000e+02 1.84800000e+03 1.64780000e+04 1.63548000e+05
5.50000000e+00 3.30000000e+01 2.94250000e+02 2.92050000e+03
2.20000000e+01 1.32000000e+02 1.17700000e+03 1.16820000e+04
1.29250000e+02 7.75500000e+02 6.91487500e+03 6.86317500e+04
8.47000000e+02 5.08200000e+03 4.53145000e+04 4.49757000e+05
1.70000000e+01 1.02000000e+02 9.09500000e+02 9.02700000e+03
6.80000000e+01 4.08000000e+02 3.63800000e+03 3.61080000e+04
3.99500000e+02 2.39700000e+03 2.13732500e+04 2.12134500e+05
2.61800000e+03 1.57080000e+04 1.40063000e+05 1.39015800e+06]]



Last Updated : 31 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads