Differentiate a Hermite series with multidimensional coefficients in Python

To differentiate a Hermite series with multidimensional coefficients, use the hermite.hermder() method in Python. This function handles multidimensional arrays where different axes correspond to different variables.

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 (default: 1). Must be non-negative
  • scl: Scalar multiplier for each differentiation (default: 1). Final result is multiplied by scl**m
  • axis: Axis over which the derivative is taken (default: 0)

Example

Let's differentiate a Hermite series with a 2D coefficient array ?

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...\n", c)

# Check the Dimensions
print("\nDimensions of our Array...\n", c.ndim)

# Get the Datatype
print("\nDatatype of our Array object...\n", c.dtype)

# Get the Shape
print("\nShape of our Array object...\n", c.shape)

# To differentiate a Hermite series, use the hermite.hermder() method
print("\nResult...\n", H.hermder(c))
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...
 [[4. 6.]]

Different Axis Differentiation

You can differentiate along different axes using the axis parameter ?

import numpy as np
from numpy.polynomial import hermite as H

# Create a 3x3 coefficient array
c = np.arange(9).reshape(3,3)
print("Original Array:\n", c)

# Differentiate along axis 0 (default)
result_axis0 = H.hermder(c, axis=0)
print("\nDifferentiation along axis 0:\n", result_axis0)

# Differentiate along axis 1
result_axis1 = H.hermder(c, axis=1)
print("\nDifferentiation along axis 1:\n", result_axis1)
Original Array:
 [[0 1 2]
 [3 4 5]
 [6 7 8]]

Differentiation along axis 0:
 [[ 6.  8. 10.]
 [24. 28. 32.]]

Differentiation along axis 1:
 [[ 2.  8.]
 [10. 16.]
 [18. 24.]]

Multiple Derivatives

Use the m parameter to take higher-order derivatives ?

import numpy as np
from numpy.polynomial import hermite as H

# Create coefficient array
c = np.array([[1, 2, 3], [4, 5, 6]])
print("Original Array:\n", c)

# First derivative (m=1)
first_deriv = H.hermder(c, m=1)
print("\nFirst Derivative:\n", first_deriv)

# Second derivative (m=2)
second_deriv = H.hermder(c, m=2)
print("\nSecond Derivative:\n", second_deriv)
Original Array:
 [[1 2 3]
 [4 5 6]]

First Derivative:
 [[ 8. 10. 12.]]

Second Derivative:
 [[20. 24.]]

Conclusion

The hermite.hermder() method efficiently differentiates Hermite series with multidimensional coefficients. Use the axis parameter to specify differentiation direction and m for higher-order derivatives.

Updated on: 2026-03-26T20:05:23+05:30

214 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements