Differentiate a Hermite series, set the derivatives and multiply each differentiation by a scalar in Python

To differentiate a Hermite series, use the hermite.hermder() method in Python. This function allows you to compute derivatives of Hermite polynomial series with customizable scaling factors.

Syntax

numpy.polynomial.hermite.hermder(c, m=1, scl=1, axis=0)

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. Each differentiation is multiplied by scl, resulting in final multiplication by scl**m (Default: 1)
  • axis ? Axis over which the derivative is taken (Default: 0)

Basic Differentiation

Let's start with a simple example of differentiating a 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])
print("Original coefficients:", c)

# First derivative
result = H.hermder(c, m=1)
print("First derivative:", result)
Original coefficients: [1 2 3 4]
First derivative: [ 4. 12. 48.]

Multiple Derivatives with Scaling

Here's how to compute multiple derivatives and apply scalar multiplication ?

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

# Create an array of coefficients
c = np.array([1, 2, 3, 4])
print("Our Array:")
print(c)
print("Dimensions:", c.ndim)
print("Datatype:", c.dtype)
print("Shape:", c.shape)

# Second derivative with scalar multiplication
result = H.hermder(c, m=2, scl=-1)
print("\nSecond derivative with scl=-1:")
print(result)
Our Array:
[1 2 3 4]
Dimensions: 1
Datatype: int64
Shape: (4,)

Second derivative with scl=-1:
[24. 96.]

Understanding the Scaling Factor

The scaling factor is applied to each differentiation step. For example, with m=2 and scl=-1, the result is multiplied by (-1)² = 1, but each individual derivative step is scaled by -1 ?

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

c = np.array([1, 2, 3, 4])

# Compare different scaling factors
print("Without scaling (scl=1):")
print(H.hermder(c, m=2, scl=1))

print("\nWith scl=2:")
print(H.hermder(c, m=2, scl=2))

print("\nWith scl=-1:")
print(H.hermder(c, m=2, scl=-1))
Without scaling (scl=1):
[24. 96.]

With scl=2:
[ 96. 384.]

With scl=-1:
[24. 96.]

Practical Use Case

This function is commonly used in mathematical transformations and physics calculations where you need to apply linear changes of variables ?

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

# Hermite series representing a function
coeffs = np.array([0.5, 1.0, 0.3, 0.1])
print("Original Hermite series coefficients:", coeffs)

# First derivative scaled by factor of 2 (for variable transformation)
derivative = H.hermder(coeffs, m=1, scl=2)
print("Scaled first derivative:", derivative)

# Third derivative
third_deriv = H.hermder(coeffs, m=3)
print("Third derivative:", third_deriv)
Original Hermite series coefficients: [0.5 1.  0.3 0.1]
Scaled first derivative: [2.  1.2 1.2]
Third derivative: [2.4]

Conclusion

The hermite.hermder() function provides flexible differentiation of Hermite series with customizable derivative orders and scaling factors. The scaling parameter is particularly useful for handling linear variable transformations in mathematical and scientific applications.

Updated on: 2026-03-26T20:16:46+05:30

244 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements