Open In App

Evaluate a 3D Laguerre series at points (x,y,z) using NumPy in Python

Last Updated : 03 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to evaluate a 3D Laguerre series at points (x,y,z) using NumPy in Python.

numpy.polynomial.legendre.legval3d

The numpy.polynomial.legendre.legval3d() method from the NumPy library is used to evaluate a 3D Laguerre series at points(x,y,z) in Python. Only tuples or lists are transformed to arrays; otherwise, x, y, and z are handled as scalars and must have the same shape after conversion. In either instance, x, y, and z, or their elements, must be able to perform multiplication and addition among themselves and with the constituents of c. If the shape of c has fewer than three dimensions, ones are implicitly added to make it three-dimensional. c.shape[3:] + x.shape is the shape of the final product.

Syntax: polynomial.legendre.legval3d(x, y, z, c)

Parameters:

  • x,y,z: array like objects. The three-dimensional series is assessed at the points (x, y, z), 
  • c: array like object. The coefficient of the term of multi-degree i,j,k is contained in c[i,j,k]

Return:  values: ndarray. The multidimensional polynomial’s values.

Example 1:

Here, we will create a NumPy array and use polynomial.legendre.legval3d(x, y, z, c) to evaluate a 3D Laguerre series at points(x,y,z). x,y,z represents 3D points and c is the array of Coefficients. The shape of the array is found by the .shape attribute, the dimension of the array is found by the .ndim attribute, and the data type of the array is the .dtype attribute.

Python3




# importing packages
import numpy as np
from numpy.polynomial import legendre as L
  
# array of coefficients
array = np.array([[[10,20],[30,40]]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# evaluating a 3D languerre series
print(L.legval3d([2,3],[2,3],[2,3],array))


Output:

[[[10 20]
  [30 40]]]
Shape of the array is :  (1, 2, 2)
The dimension of the array is :  3
[270. 520.]

Example 2:

Here, we will create a NumPy array and use polynomial.legendre.legval3d(x, y, z, c) to evaluate a 3D Laguerre series at points(x,y,z). x,y,z represents 3D points and c is the array of Coefficients. The shape of the array is found by the .shape attribute, the dimension of the array is found by the .ndim attribute, and the data type of the array is the .dtype attribute.

Python3




# importing packages
import numpy as np
from numpy.polynomial import legendre as L
  
# array of coefficients
array = np.array([[[40,30],[12,15]]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",array.dtype)
  
# evaluating a 3D languerre series
print(L.legval3d([1.3,3],[2,3.5],[2,3],array))


Output:

[[[40 30]
  [12 15]]]
Shape of the array is :  (1, 2, 2)
The dimension of the array is :  3
Datatype of our Array is :  int32
[184.  329.5]


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads