Differentiate Hermite series and multiply each differentiation by scalar using NumPy in Python

The Hermite_e series (probabilist's Hermite polynomial) is a mathematical function used in quantum mechanics and probability theory. NumPy provides the hermite.hermder() function to differentiate Hermite series and multiply each differentiation by a scalar value.

Hermite_e Series Formula

The Hermite_e polynomial is defined as:

H_n(x) = (?1)^n e^(x²/2) d^n/dx^n(e^(?x²/2))

Where:

  • H_n(x) is the nth Hermite polynomial of degree n

  • x is the independent variable

  • d^n/dx^n denotes the nth derivative with respect to x

Syntax

The polynomial.hermite.hermder() function syntax is:

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

Parameters:

  • c ? Array of Hermite series coefficients

  • m ? Number of derivatives taken (default: 1)

  • scl ? Scalar multiplier for each differentiation (default: 1)

  • axis ? Axis over which the derivative is taken (default: 0)

Example 1: Basic Differentiation with Scalar

Let's differentiate a Hermite series and multiply by scalar value 3:

import numpy as np
from numpy.polynomial import hermite

# Create 3D array of coefficients
coefficients = np.arange(-10, 14, 2).reshape(2, 3, 2)
print("The coefficient values:")
print(coefficients)

# First derivative with scalar multiplication
diff_coefficients = hermite.hermder(coefficients, m=1, scl=3)
print("\nThe derivative of the coefficient values:")
print(diff_coefficients)
The coefficient values:
[[[-10  -8]
  [ -6  -4]
  [ -2   0]]

 [[  2   4]
  [  6   8]
  [ 10  12]]]

The derivative of the coefficient values:
[[[12. 24.]
  [36. 48.]
  [60. 72.]]]

Example 2: Second-Order Derivative

Computing the second derivative of a 2D coefficient array:

import numpy as np
from numpy.polynomial import hermite

# Create 2D array of coefficients
coefficients = np.arange(-40, 14, 4).reshape(7, 2)
print("The coefficient values:")
print(coefficients)

# Second-order derivative
diff_coefficients = hermite.hermder(coefficients, m=2, scl=1)
print("\nThe 2nd order derivative:")
print(diff_coefficients)
The coefficient values:
[[-40 -36]
 [-32 -28]
 [-24 -20]
 [-16 -12]
 [ -8  -4]
 [  0   4]
 [ 8  12]]

The 2nd order derivative:
[[-192. -160.]
 [-384. -288.]
 [-384. -192.]
 [   0.  320.]
 [ 960. 1440.]]

Example 3: Higher-Order Derivative with Custom Function

Creating a function to compute third-order derivatives with negative scaling:

import numpy as np
from numpy.polynomial import hermite

def differentiate_hermite(coefficients, order, scalar):
    print("The coefficient values:")
    print(coefficients)
    
    diff_coefficients = hermite.hermder(coefficients, m=order, scl=scalar)
    print(f"\nThe {order} order derivative (scalar={scalar}):")
    print(diff_coefficients)

# Apply third derivative with scalar -3
coeffs = np.linspace(-10, 20, 10)
differentiate_hermite(coeffs, 3, -3)
The coefficient values:
[-10.          -6.66666667  -3.33333333   0.           3.33333333
   6.66666667  10.          13.33333333  16.66666667  20.        ]

The 3 order derivative (scalar=-3):
[-720.  -480.  -240.     0.   240.   480.   720.]

Example 4: Default Parameters

Using default values (first derivative with scalar 1):

import numpy as np
from numpy.polynomial import hermite

# Using default parameters: m=1, scl=1
coefficients = np.array([1, 2, 3, 4, 5])
print("Original coefficients:", coefficients)

# Default first derivative
result = hermite.hermder(coefficients)
print("First derivative (default):", result)
Original coefficients: [1 2 3 4 5]
First derivative (default): [2. 6. 12. 20.]

Key Points

  • Higher-order derivatives reduce the array size by m elements

  • The scl parameter multiplies each derivative operation

  • Default values are m=1 and scl=1

  • Works with multidimensional coefficient arrays

Conclusion

The hermite.hermder() function efficiently computes derivatives of Hermite series with scalar multiplication. Use the m parameter for derivative order and scl for scaling each differentiation step.

Updated on: 2026-03-27T15:54:26+05:30

164 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements