Open In App

Differentiate a Hermite_e series in Python

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to differentiate a Hermite_e series in Python using NumPy.

np.polynomial.hermite_e.hermeder method

To Differentiate a Hermite series in python we use the NumPy.polynomial.hermite_e.hermeder() method which is used to return the c differentiated m times along the axis series coefficients. Where, the argument c is an array of coefficients ranging in degree from low to high along each axis, such as [4,3,5], which represents the series 4*He 0 + 3*He 1 + 5*He 2. Below is the syntax of the hermeder method.

 Syntax: numpy.polynomial.hermite_e.hermeder(c, m=1, scl=1, axis=0)

Parameters:

  • c: array like object. The coefficients of the Hermite e series are stored in an array. If c is multidimensional, the various axes correspond to various variables, with the degree in each axis being determined by the appropriate index.
  • m: int , optional value. The total number of derivatives taken must not be negative. (Standard: 1).
  • scl: scalar, optional value. scl is multiplied by each differentiation. Multiplication by scl**m is the end result. This is for when you want to make a linear change in a variable. (Standard: 1).
  • axis: int , optional value. The axis on which the derivative is computed. (The default is 0).

Return: der: ndarray.The derivative of Hermite series.

Example 1:

Here, we will create a NumPy array and use numpy.polynomial.hermite_e.hermeder() to differentiate the Hermite series. The shape of the array is found by the .shape attribute, the dimension of the array is found by .ndim attribute, and the data type of the array is .dtype attribute. 

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite_e as H
 
# Creating an array
array = np.array([4,2,5])
print(array)
 
# shape of the array is
print("Shape of the array is: ", array.shape)
 
# dimension of the array
print("The dimension of the array is: ", array.ndim)
 
# datatype of the array
print("Datatype of our Array is: ", array.dtype)
 
# differentiating a hermite series
print(H.hermeder(array, axis=0,m=1))


Output:

[4 2 5]
Shape of the array is :  (3,)
The dimension of the array is :  1
Datatype of our Array is :  int64
[ 2. 10.]

Example 1:

In this example, we create a 2-d series and differentiate it along with the columns ( axis =1).

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite_e as H
 
# Creating an array
array = np.array([[4,2,5],[1,4,2]])
print(array)
 
# shape of the array is
print("Shape of the array is: ", array.shape)
 
# dimension of the array
print("The dimension of the array is: ", array.ndim)
 
# Datatype of the array
print("Datatype of our Array is: ", array.dtype)
 
# differentiating a hermite series
print(H.hermeder(array,axis=1,m=2))


Output:

[[4 2 5]
 [1 4 2]]
Shape of the array is :  (2, 3)
The dimension of the array is :  2
Datatype of our Array is :  int64
[[10.]
 [ 4.]]


Last Updated : 03 May, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads