# Differentiate a Hermite series and set the derivatives in Python

• Last Updated : 04 May, 2022

In this article, we are going to cover how to differentiate a Hermite series and set the derivatives in Python using NumPy.

## numpy.polynomial.hermite.hermder method

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)

Parameters

• 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.

### Example 1

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.

## Python3

 `import` `numpy as np` `import` `numpy.polynomial.hermite as H`   `# Create an array of coefficients` `c ``=` `np.array([``14``, ``5``, ``34``])`   `# coefficient array before differentiation` `print``(``"coef array before diff->"``, c)`   `# use hermder method to differentiate the` `# hermite series` `print``(``"coef array after diff->"``, H.hermder(c, m``=``2``))`

Output:

```coef array before diff-> [14  5 34]
coef array after diff-> [272.]```

### Example 2

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.

## Python3

 `import` `numpy as np` `import` `numpy.polynomial.hermite as H`   `# Create an array of coefficients` `c ``=` `np.array([``14``, ``5``, ``34``])`   `# coefficient array before differentiation` `print``(``"coef array before diff->"``, c)`   `# use hermder method to differentiate the` `# hermite series` `print``(``"coef array after diff->"``, H.hermder(c, m``=``2``, scl``=``3``))`

Output:

```coef array before diff-> [14  5 34]
coef array after diff-> [2448.]```

### Example 3

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.

## Python3

 `import` `numpy as np` `import` `numpy.polynomial.hermite as H`   `# Create an array of coefficients` `c ``=` `np.array([[``1``, ``4``, ``3``, ``4``], [``8``, ``9``, ``2``, ``5``]])`   `# coefficient array before differentiation` `print``(``"coef array before diff->"``, c)`   `# use hermder method to differentiate ` `# the hermite series` `print``(``"coef array after diff->"``, H.hermder(c, m``=``2``, scl``=``2``, axis``=``1``))`

Output:

```coef array before diff-> [[1 4 3 4]
[8 9 2 5]]
coef array after diff-> [[ 96. 384.]
[ 64. 480.]]```

My Personal Notes arrow_drop_up
Recommended Articles
Page :