Evaluate a Hermite_e series at list of points x using NumPy in Python
In this article, we will cover how to evaluate a Hermite_e series at the list of points x using NumPy in Python.
numpy.polynomial.hermite.hermval
To evaluate a Hermite series at points x with a multidimensional coefficient array, NumPy provides a function called hermite.hermval(). It takes two parameters x and c. whereas x is a tuple or list. It is considered a scalar. But, the parameter x should support multiplication and addition within itself and with the elements of c. If c is a 1-D array, then it will have the same shape as x. If c is multidimensional, then the shape of the result depends on the value of the tensor.
Syntax: numpy.polynomial.hermite.hermval
Parameters:
- x: array like object.
- c: Array of coefficients
- tensor: optional value, boolean type.
Returns: ndarray of Hermite_e series
Example 1:
The NumPy package is imported. An array is created which represents coefficients of the Hermite series. polynomial.hermite.hermval() is used to evaluate a Hermite series at a list of points x. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. x is a list.
Python3
import numpy as np
from numpy.polynomial import hermite as H
array = np.array([ 10 , 20 , 30 , 40 ])
print (array)
print ( "Shape of the array is : " ,array.shape)
print ( "The dimension of the array is : " ,array.ndim)
print (H.hermval([ 1 , 2 , 3 ],array))
|
Output:
[10 20 30 40]
Shape of the array is : (4,)
The dimension of the array is : 1
[ -50. 2110. 8350.]
Example 2:
The NumPy package is imported. An array is created using NumPy, which represents coefficients of the Hermite series. polynomial.hermite.hermval() is used to evaluate a Hermite series at a list of points x, where x is [2,3,4]. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. x is a list.
Python3
import numpy as np
from numpy.polynomial import hermite as H
array = np.array([ 20 , 30 , 40 , 45 ])
print (array)
print ( "Shape of the array is : " ,array.shape)
print ( "The dimension of the array is : " ,array.ndim)
print (H.hermval([ 2 , 3 , 4 ],array, tensor = False ))
|
Output:
[20 30 40 45]
Shape of the array is : (4,)
The dimension of the array is : 1
[ 2500. 9660. 23620.]
Last Updated :
03 Jun, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...