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 series with multidimensional coefficients over specific axis in Python
To differentiate a Hermite series with multidimensional coefficients, use the hermite.hermder() method in Python. This function allows you to compute derivatives along specific axes of multidimensional coefficient arrays.
Syntax
hermite.hermder(c, m=1, scl=1, axis=0)
Parameters
The hermder() method accepts the following parameters ?
- c ? Array of Hermite series coefficients. For multidimensional arrays, different axes correspond to different variables
- m ? Number of derivatives to take (default: 1). Must be non-negative
- scl ? Scalar multiplier for each differentiation (default: 1). Final result is multiplied by scl**m
- axis ? Axis along which the derivative is computed (default: 0)
Example
Let's create a multidimensional coefficient array and differentiate along different axes ?
import numpy as np
from numpy.polynomial import hermite as H
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2, 2)
# 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)
# Differentiate along axis 1
print("\nResult (axis=1)...")
print(H.hermder(c, axis=1))
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 (axis=1)... [[2.] [6.]]
Differentiating Along Different Axes
You can specify different axes for differentiation ?
import numpy as np
from numpy.polynomial import hermite as H
c = np.arange(6).reshape(2, 3)
print("Original coefficient array:")
print(c)
# Differentiate along axis 0 (default)
print("\nDerivative along axis 0:")
print(H.hermder(c, axis=0))
# Differentiate along axis 1
print("\nDerivative along axis 1:")
print(H.hermder(c, axis=1))
Original coefficient array: [[0 1 2] [3 4 5]] Derivative along axis 0: [[6. 8. 10.]] Derivative along axis 1: [[ 2. 8.] [ 8. 20.]]
Using Multiple Derivatives and Scaling
The method also supports higher-order derivatives and scaling factors ?
import numpy as np
from numpy.polynomial import hermite as H
c = np.array([[1, 2, 3], [4, 5, 6]])
print("Original coefficients:")
print(c)
# Second derivative with scaling
print("\nSecond derivative (m=2, scl=2):")
print(H.hermder(c, m=2, scl=2, axis=1))
Original coefficients: [[1 2 3] [4 5 6]] Second derivative (m=2, scl=2): [[48.] [96.]]
Conclusion
The hermite.hermder() method provides flexible differentiation of Hermite series with multidimensional coefficients. Use the axis parameter to control which dimension to differentiate along, and adjust m and scl for higher-order derivatives and scaling.
