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
Selected Reading
Differentiate a Hermite series in Python
To differentiate a Hermite series, use the hermite.hermder() method in Python. This function computes the derivative of a Hermite series represented by its coefficients.
Syntax
numpy.polynomial.hermite.hermder(c, m=1, scl=1, axis=0)
Parameters
The hermder() method accepts the following parameters ?
- c ? Array of Hermite series coefficients. If multidimensional, different axes correspond to different variables.
- m ? Number of derivatives taken, 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).
Basic Example
Let's differentiate a simple Hermite series ?
import numpy as np
from numpy.polynomial import hermite 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 and properties
print("\nDimensions of our Array...")
print(c.ndim)
print("\nDatatype of our Array object...")
print(c.dtype)
print("\nShape of our Array object...")
print(c.shape)
# Differentiate the Hermite series
print("\nFirst derivative...")
print(H.hermder(c))
Our Array... [1 2 3 4] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) First derivative... [ 4. 12. 24.]
Multiple Derivatives
You can compute higher-order derivatives by specifying the m parameter ?
import numpy as np
from numpy.polynomial import hermite as H
c = np.array([1, 2, 3, 4, 5])
print("Original coefficients:")
print(c)
print("\nFirst derivative (m=1):")
print(H.hermder(c, m=1))
print("\nSecond derivative (m=2):")
print(H.hermder(c, m=2))
print("\nThird derivative (m=3):")
print(H.hermder(c, m=3))
Original coefficients: [1 2 3 4 5] First derivative (m=1): [ 4. 12. 24. 40.] Second derivative (m=2): [ 24. 96. 240.] Third derivative (m=3): [192. 960.]
Using Scale Factor
The scl parameter allows you to scale the derivative ?
import numpy as np
from numpy.polynomial import hermite as H
c = np.array([1, 2, 3, 4])
print("Original derivative:")
print(H.hermder(c))
print("\nDerivative with scale factor 2:")
print(H.hermder(c, scl=2))
print("\nSecond derivative with scale factor 0.5:")
print(H.hermder(c, m=2, scl=0.5))
Original derivative: [ 4. 12. 24.] Derivative with scale factor 2: [ 8. 24. 48.] Second derivative with scale factor 0.5: [ 3. 12.]
Conclusion
The hermite.hermder() method efficiently computes derivatives of Hermite series. Use the m parameter for higher-order derivatives and scl for scaling transformations.
Advertisements
