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 2-D Hermite_e series at points (x,y) with 3D array of coefficient in Python
To evaluate a 2D Hermite_e series at points (x, y), use the hermeval2d() method from NumPy's polynomial module. This function evaluates a two-dimensional Hermite_e polynomial at specified coordinate pairs.
Syntax
numpy.polynomial.hermite_e.hermeval2d(x, y, c)
Parameters
The function accepts three parameters:
- x, y − Arrays of coordinates where x and y must have the same shape. The series is evaluated at points (x, y)
- c − Array of coefficients where c[i,j] contains the coefficient for the term of multidegree i,j. For higher dimensions, remaining indices represent multiple coefficient sets
Example
Let's create a 3D coefficient array and evaluate the Hermite_e series at specific points ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create a 3D array of coefficients
c = np.arange(24).reshape(2, 2, 6)
# Display the array
print("Coefficient Array:")
print(c)
# Check array properties
print(f"\nDimensions: {c.ndim}")
print(f"Shape: {c.shape}")
print(f"Datatype: {c.dtype}")
# Evaluate the 2D Hermite_e series at points (x, y)
result = H.hermeval2d([1, 2], [1, 2], c)
print("\nEvaluation Result:")
print(result)
Coefficient 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]]] Dimensions: 3 Shape: (2, 2, 6) Datatype: int64 Evaluation Result: [[ 36. 108.] [ 40. 117.] [ 44. 126.] [ 48. 135.] [ 52. 144.] [ 56. 153.]]
How It Works
The function evaluates the 2D Hermite_e series using the coefficient array structure. With a 3D coefficient array of shape (2, 2, 6), the first two dimensions (2, 2) define the polynomial degree structure, while the third dimension (6) represents multiple sets of coefficients. Each coefficient set produces one column in the output result.
Key Points
- Input coordinates x and y must have identical shapes
- The coefficient array c[i,j] stores coefficients for polynomial terms of degree (i,j)
- Higher dimensional coefficient arrays enable evaluation of multiple polynomial sets simultaneously
- The output shape depends on both the input coordinates and coefficient array dimensions
Conclusion
The hermeval2d() function provides an efficient way to evaluate 2D Hermite_e polynomials at specified points. It handles both simple 2D coefficient arrays and higher-dimensional arrays for batch evaluation of multiple polynomial sets.
