Differentiate a Hermite series and set the derivatives in Python
To differentiate the Hermite series python provides a method called hermite.hermder which is present in the NumPy package. This method accepts an array of Hermite series coefficients and also a number that specifies the number of times derivatives to be taken. It returns an array containing coefficients of differentiated Hermite series. It helps us to differentiate the Hermite series which is a classical orthogonal polynomial sequence. The syntax of the hermder method is given as:
Syntax: numpy.polynomial.hermite.hermder(coefficient_array, m=1, scl=1, axis=0)
- coefficient_array: Array of coefficients of Hermite series
- m: Number of times derivative is taken. It’s optional and should be non negative. Default value=1
- scl: A scalar quantity which is multiplied with the result after each differentiation. Optional parameter.
- axis: Specifies over which axis derivative is taken. Optional and default value is 0.
Returns an array of coefficients of differentiated Hermite series.
In the above code we considered a single-dimensional array and performed differentiation 2 times as we passed m=2. scl parameter is not passed so it considers as 1 by default.
coef array before diff-> [14 5 34] coef array after diff-> [272.]
Here we considered the same array of coefficients as considered in the example-1 but here we passed an scl parameter to hermder method which multiplies the array of coefficients after each differentiation with scl value. So this scl value leads to a different result.
coef array before diff-> [14 5 34] coef array after diff-> [2448.]
Here we passed a two-dimensional array of coefficients and differentiated the Hermite series 2 times along the axis 1. The result after each differentiation is multiplied with scalar value 2.
coef array before diff-> [[1 4 3 4] [8 9 2 5]] coef array after diff-> [[ 96. 384.] [ 64. 480.]]