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, set the derivatives and multiply each differentiation by a scalar in Python
To differentiate a Hermite_e series, use the hermite_e.hermeder() method in Python. This function allows you to compute derivatives and apply scalar multiplication to each differentiation step.
Syntax
numpy.polynomial.hermite_e.hermeder(c, m=1, scl=1, axis=0)
Parameters
The function accepts the following parameters ?
- c ? Array of Hermite_e series coefficients. For multidimensional arrays, different axes correspond to different variables
- m ? Number of derivatives to take (must be non-negative, default: 1)
- scl ? Scalar multiplier for each differentiation. Final result is multiplied by scl**m (default: 1)
- axis ? Axis over which the derivative is taken (default: 0)
Example
Let's create a Hermite_e series and compute its second derivative with scalar multiplication ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of coefficients
c = np.array([1, 2, 3, 4])
# Display the array
print("Our Array...")
print(c)
# Check the Dimensions
print("\nDimensions of our Array...")
print(c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...")
print(c.dtype)
# Get the Shape
print("\nShape of our Array object...")
print(c.shape)
# To differentiate a Hermite_e series, use the hermite_e.hermeder() method
# Taking 2nd derivative with scalar multiplier -1
print("\nResult...")
print(H.hermeder(c, 2, scl=-1))
Our Array... [1 2 3 4] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) Result... [ 6. 24.]
How It Works
The original polynomial represented by coefficients [1, 2, 3, 4] corresponds to:
P(x) = 1 + 2x + 3x² + 4x³
Taking the second derivative and multiplying by scl = -1 twice (giving (-1)² = 1), we get coefficients [6, 24], representing 6 + 24x.
Multiple Derivatives with Different Scalars
import numpy as np
from numpy.polynomial import hermite_e as H
c = np.array([1, 2, 3, 4, 5])
# First derivative
first_deriv = H.hermeder(c, m=1)
print("First derivative:", first_deriv)
# Second derivative with scalar 2
second_deriv = H.hermeder(c, m=2, scl=2)
print("Second derivative (scl=2):", second_deriv)
# Third derivative with scalar -1
third_deriv = H.hermeder(c, m=3, scl=-1)
print("Third derivative (scl=-1):", third_deriv)
First derivative: [ 2. 6. 12. 20.] Second derivative (scl=2): [24. 96. 320.] Third derivative (scl=-1): [-144. -1280.]
Conclusion
The hermite_e.hermeder() method efficiently computes derivatives of Hermite_e series with optional scalar multiplication. Use the scl parameter for linear variable transformations and m to specify the derivative order.
