Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Evaluate a 3D Laguerre series at points (x,y,z) with 4D array of coefficient in Python
To evaluate a 3D Laguerre series at points (x,y,z), use the polynomial.laguerre.lagval3d() method in Python NumPy. The method returns the values of the multidimensional polynomial on points formed with triples of corresponding values from x, y, and z.
If the coefficient array c has fewer than 3 dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape.
Syntax
polynomial.laguerre.lagval3d(x, y, z, c)
Parameters
x, y, z − The three-dimensional series is evaluated at points (x, y, z), where x, y, and z must have the same shape. If any of x, y, or z is a list or tuple, it is first converted to an ndarray.
c − Array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in c[i,j,k]. If c has dimension greater than 3, the remaining indices enumerate multiple sets of coefficients.
Example
Let's create a 4D array of coefficients and evaluate the 3D Laguerre series at specific points ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create a 4D array of coefficients
c = np.arange(48).reshape(2, 2, 6, 2)
# Display the array
print("Our Array...\n", c)
# Check the dimensions
print("\nDimensions of our Array...\n", c.ndim)
# Get the datatype
print("\nDatatype of our Array object...\n", c.dtype)
# Get the shape
print("\nShape of our Array object...\n", c.shape)
# Evaluate 3D Laguerre series at points (1,2), (1,2), (1,2)
print("\nResult...\n", L.lagval3d([1, 2], [1, 2], [1, 2], c))
Our Array... [[[[ 0 1] [ 2 3] [ 4 5] [ 6 7] [ 8 9] [10 11]] [[12 13] [14 15] [16 17] [18 19] [20 21] [22 23]]] [[[24 25] [26 27] [28 29] [30 31] [32 33] [34 35]] [[36 37] [38 39] [40 41] [42 43] [44 45] [46 47]]]] Dimensions of our Array... 4 Datatype of our Array object... int64 Shape of our Array object... (2, 2, 6, 2) Result... [[-15.66666667 0. ] [-16.925 0. ]]
How It Works
The function evaluates the 3D Laguerre polynomial using the coefficient array. Each point (x[i], y[i], z[i]) produces a result based on the polynomial defined by the coefficients. The 4D coefficient array allows for multiple polynomial evaluations simultaneously.
Key Points
- Input coordinates x, y, z must have the same shape
- Coefficient array c should be at least 3-dimensional
- The result shape follows the pattern
c.shape[3:] + x.shape - Lists and tuples for coordinates are automatically converted to ndarrays
Conclusion
The lagval3d() method provides an efficient way to evaluate 3D Laguerre series at multiple points simultaneously. It's particularly useful for mathematical computations involving multi-dimensional polynomial approximations.
