Evaluate a Hermite_e series at points x when coefficients are multi-dimensional in Python
In this article, we will discuss how to evaluate a Hermite_e series at points x when coefficients are multi-dimensional in Python
We use the hermite.hermeval() function from the numpy module.
Syntax: hermite_e.hermeval(x,Arr)
Parameters :
- x (required parameter): ‘x’ can be a single number or list of numbers but the only condition is the ‘x’ or the elements in ‘x’ should support the operations like addition and multiplication among themselves and with the elements in ‘Arr’
(which is the second parameter to be passed). ‘x’ will be transformed to ndarray if it is a tuple or a list, otherwise it will consider as a scaler.
- Arr (required parameter): ‘Arr’ is an array of coefficients that is sorted in such a way that the coefficients for terms of degree n
are present in Arr[n]. In our case the array is multi-dimensional array of coefficients.
Stepwise Implementation
Step 1: Import NumPy and hermite_e libraries :
import numpy as np
from numpy.polynomial import hermite_e as H
Step 2: Now we have to create a multidimensional array ‘Arr’ of coefficients with any of style as shown below :
Arr = np.arange(4).reshape(2,2)
OR
Arr = np.matrix([[0,1],[2,3]])
OR
Arr = [[0,1],[2,3]]
Step 3: To evaluate a Hermite_e series at points x for multidimensional coefficients, use the hermite.hermeval() method in Numpy module as shown below :
print(H.hermeval([1,2],Arr))
Example 1 :
Python3
import numpy as np
from numpy.polynomial import hermite_e as HE
Arr = np.matrix([[ 1 , 3 ], [ 4 , 5 ]])
print (HE.hermeval([ 2 , 3 ], Arr))
|
Output :
[[ 9. 13.]
[13. 18.]]
Example 2 :
Python3
from numpy.polynomial import hermite_e as H
Mul_Array = [[ 2 , 2 ], [ 4 , 3 ]]
print (H.hermeval([ 2 , 1 ], Mul_Array))
|
Output :
[[10. 6.]
[ 8. 5.]]
Last Updated :
25 Apr, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...