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) in Python
To evaluate a 2D Hermite_e series at points (x, y), use the hermite_e.hermeval2d() method in NumPy. This method returns the values of the two-dimensional polynomial at points formed with pairs of corresponding values from x and y.
Syntax
numpy.polynomial.hermite_e.hermeval2d(x, y, c)
Parameters
The function takes three parameters:
- x, y − The two dimensional series is evaluated at points (x, y), where x and y must have the same shape. If x or y 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 is contained in c[i,j]. If c has dimension greater than two, the remaining indices enumerate multiple sets of coefficients
Example
Let's create a 2D 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 multidimensional array of coefficients
c = np.arange(4).reshape(2,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)
# To evaluate a 2D Hermite_e series at points (x, y), use the hermeval2d() method
print("\nResult...\n", H.hermeval2d([1,2], [1,2], c))
Our Array... [[0 1] [2 3]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result... [ 6. 18.]
How It Works
The coefficient matrix c represents the 2D Hermite_e polynomial:
- c[0,0] = 0 (coefficient for H_e0(x) * H_e0(y))
- c[0,1] = 1 (coefficient for H_e0(x) * H_e1(y))
- c[1,0] = 2 (coefficient for H_e1(x) * H_e0(y))
- c[1,1] = 3 (coefficient for H_e1(x) * H_e1(y))
For points (1,1) and (2,2), the function evaluates the polynomial and returns the corresponding values [6., 18.].
Conclusion
The hermeval2d() method efficiently evaluates 2D Hermite_e series at multiple points simultaneously. The coefficient array structure directly maps to polynomial terms, making it straightforward to define complex 2D polynomials.
