Understanding Hermite Series Multiplication using numpy.polynomial.hermite_e.hermemul()


Hermite polynomials are a specific type of polynomial employed in approximating functions and solving differential equations. They're characterized by the property that their derivatives at x = 0 are all 1.

The hermemul function takes two arguments, both of which are coefficient sequences representing Hermite series. These sequences are listed from the lowest to highest order terms. For instance, [1, 2, 3] represents the polynomial P_0 + 2P_1 + 3P_2, where P_i denotes the ith-degree Hermite polynomial.

The function computes the product of the two provided Hermite series and returns a new coefficient array that represents the resulting polynomial.

import numpy as np

def hermite_example():
    """
    Example usage of hermemul function
    """
    coef1 = np.array([1, 2, 3])  # Represents 1*P_0 + 2*P_1 + 3*P_2
    coef2 = np.array([2, 1])  # Represents 2*P_0 + 1*P_1
    res = np.polynomial.hermite_e.hermemul(coef1, coef2)
    print(res)

if __name__ == "__main__":
    hermite_example()

This code defines a function hermite_example that creates two sample coefficient arrays coef1 and coef2 representing Hermite series. It then utilizes hermemul to calculate their product and stores the outcome in the res variable. Finally, it prints the res array, which holds the coefficients of the resultant polynomial after multiplication.

Running this code snippet will output the following:

[ 4. 11.  8.  3.]


import numpy as np

def hermite_eval_example():
    """
    Example using hermemul to evaluate product of Hermite series
    """
    coef1 = np.array([1, 2, 3])  # Represents 1*P_0 + 2*P_1 + 3*P_2
    coef2 = np.array([2, 1])  # Represents 2*P_0 + 1*P_1
    x = 0.5  # Point of evaluation

    # Compute product coefficients using hermemul
    product_coef = np.polynomial.hermite_e.hermemul(coef1, coef2)

    # Leverage hermeval to evaluate the resulting polynomial at x
    result = np.polynomial.hermite_e.hermeyeval(product_coef, x)
    print("Product of Hermite series at x =", result)

if __name__ == "__main__":
    hermite_eval_example()

This code defines a function hermite_eval_example that follows these steps:

  1. Defines sample coefficients coef1 and coef2 for Hermite series.
  2. Sets the point of evaluation x to 0.5.
  3. Employs hermemul to compute the coefficients of the product polynomial and stores them in product_coef.
  4. Utilizes numpy.polynomial.hermite_e.hermeyeval to assess the value of the resultant polynomial (represented by product_coef) at x. The outcome is stored in result.
  5. Prints the value of the product series at x.

This code snippet will output something like:

Product of Hermite series at x = 5.75


  1. Manual Polynomial Multiplication
    You can implement the conventional polynomial multiplication algorithm to multiply the two Hermite series expressed in coefficient form. This involves multiplying each term of one series with every term of the other and accumulating the corresponding terms based on their degree.

  2. Convolution with numpy.convolve
    If you're working with NumPy arrays, you can leverage the numpy.convolve function for polynomial multiplication. It's designed for general array convolution, but it can be applied to multiply polynomials by considering the coefficients as the arrays to be convolved.