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
Differentiate a Hermite_e series and set the derivatives in Python
The Hermite_e series (probabilist's Hermite polynomials) is a mathematical series used in quantum mechanics and probability theory. The weight function is e^(−x²/2). This guide shows how to differentiate Hermite_e series using NumPy's polynomial module.
Formula
The Hermite_e polynomial formula is:
H_n(x) = (−1)^n e^(x²/2) d^n/dx^n(e^(−x²/2))
Where:
- H_n(x) is the nth Hermite polynomial of degree n
- x is the independent variable
- d^n/dx^n denotes the nth derivative with respect to x
Basic Hermite_e Series Differentiation
To differentiate a Hermite_e series, use hermite_e.hermeder() function with coefficient arrays ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create coefficient array
coefficients = np.array([1, 2, 3, 4])
print("Coefficients:", coefficients)
# Differentiate once
first_derivative = H.hermeder(coefficients, m=1)
print("First derivative:", first_derivative)
# Differentiate three times
third_derivative = H.hermeder(coefficients, m=3)
print("Third derivative:", third_derivative)
Coefficients: [1 2 3 4] First derivative: [ 2. 6. 12.] Third derivative: [24.]
Evaluating Hermite_e Series
Generate and differentiate a Hermite_e series at specific points using hermeval() ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Define coefficients and evaluation points
coefficients = [-2, -4, 7, -1, 5]
x = np.linspace(-2, 2, 10)
# Evaluate the series
series_values = H.hermeval(x, coefficients)
print("Series values:")
print(series_values)
# Get derivative coefficients
derivative_coeffs = H.hermeder(coefficients, m=2)
print("\nSecond derivative coefficients:", derivative_coeffs)
# Evaluate the second derivative
derivative_values = H.hermeval(x, derivative_coeffs)
print("Second derivative values:")
print(derivative_values)
Series values: [ 549. 207. 63. 7. -13. -13. 7. 63. 207. 549.] Second derivative coefficients: [ 42. -6. 60.] Second derivative values: [ 2520. 954. 460. 138. -112. -112. 138. 460. 954. 2520.]
Working with Multi-dimensional Arrays
For 2D arrays, specify the axis along which to compute derivatives ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create 2D coefficient array
coeffs_2d = np.array([[1, 2, 3], [4, 5, 6]])
print("2D coefficients:")
print(coeffs_2d)
# Differentiate along axis 0
deriv_axis0 = H.hermeder(coeffs_2d, m=1, axis=0)
print("\nDerivative along axis 0:")
print(deriv_axis0)
# Differentiate along axis 1
deriv_axis1 = H.hermeder(coeffs_2d, m=1, axis=1)
print("\nDerivative along axis 1:")
print(deriv_axis1)
2D coefficients: [[1 2 3] [4 5 6]] Derivative along axis 0: [[4. 5. 6.]] Derivative along axis 1: [[ 2. 6.] [ 5. 12.]]
Parameters
| Parameter | Description | Default |
|---|---|---|
c |
Coefficient array | Required |
m |
Number of derivatives | 1 |
axis |
Axis along which to differentiate | 0 |
Conclusion
Use hermite_e.hermeder() to differentiate Hermite_e series by specifying the coefficient array and derivative order. The function returns new coefficients representing the differentiated series, which can be evaluated at specific points using hermeval().
