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 Hermite_e series at tuple of points x in Python
To evaluate a Hermite_e series at points x, use the hermite_e.hermeval() method in Python NumPy. The method takes coefficients and evaluation points to compute the polynomial value at each point.
Syntax
numpy.polynomial.hermite_e.hermeval(x, c, tensor=True)
Parameters
The hermeval() method accepts the following parameters ?
- x ? Array of points to evaluate. If x is a list or tuple, it is converted to an ndarray. Elements must support addition and multiplication with coefficients.
- c ? Array of coefficients ordered so that coefficients for terms of degree n are contained in c[n]. If multidimensional, remaining indices enumerate multiple polynomials.
- tensor ? If True (default), extends coefficient array shape for broadcasting. If False, x is broadcast over columns of c.
Example
Let's evaluate a Hermite_e series at multiple points using a tuple ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of coefficients
coefficients = np.array([1, 2, 3])
# Display the coefficient array
print("Coefficients:", coefficients)
print("Array shape:", coefficients.shape)
print("Array dimensions:", coefficients.ndim)
# Define evaluation points as tuple
x_points = (5, 10, 15)
print("Evaluation points:", x_points)
# Evaluate Hermite_e series at the points
result = H.hermeval(x_points, coefficients)
print("Result:", result)
Coefficients: [1 2 3] Array shape: (3,) Array dimensions: 1 Evaluation points: (5, 10, 15) Result: [ 83. 318. 703.]
How It Works
The Hermite_e polynomial is evaluated using the formula: P(x) = c[0] + c[1]*H?(x) + c[2]*H?(x) + ... where H_n(x) are the Hermite_e basis polynomials. For our coefficients [1, 2, 3], the polynomial becomes: P(x) = 1 + 2*x + 3*x².
Multiple Polynomials Example
You can evaluate multiple polynomials simultaneously using a 2D coefficient array ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create 2D coefficient array (2 polynomials)
coefficients = np.array([[1, 2], [3, 4], [5, 6]])
x_points = (1, 2, 3)
print("2D coefficients shape:", coefficients.shape)
result = H.hermeval(x_points, coefficients)
print("Results for multiple polynomials:")
print(result)
2D coefficients shape: (3, 2) Results for multiple polynomials: [[ 9. 12.] [33. 44.] [69. 92.]]
Conclusion
The hermite_e.hermeval() method efficiently evaluates Hermite_e series at multiple points. It supports both single polynomials with 1D coefficients and multiple polynomials with 2D coefficient arrays, making it versatile for various mathematical computations.
