In this article, we will be looking toward the approach to evaluating a Hermite series at a tuple of points x in Python and NumPy.
Example
Tuple: (6,7,8,9,10)
Result: [102175. 191631. 329175. 529399. 808815.]
Explanation: Hermite series at points x.
NumPy.polynomial.hermite.hermval() method
To evaluate a Hermite series at a tuple of points x, the user needs to call the hermite.hermval() method of the Numpy library in Python. Further, the user needs to pass the first parameter to the function which is the x, where x is a list or tuple, and the 2nd parameter is C, which is an array of coefficients.
Syntax : np.polynomial.hermite.hermval(x, c)
Parameter:
- x: list or tuple
- c: array of coefficient
Return : Return the coefficient of series after multiplication.
Example 1:
In this example, we created an array of 5 data points of one dimension and further created a tuple named x, then with the use of the hermite.hermval() method we pass the required parameters to evaluate the Hermite series at a tuple at points (6,7,8,9,10) in Python.
Python3
import numpy as np from numpy.polynomial import hermite a = np.array([ 1 , 2 , 3 , 4 , 5 ]) # Dimensions of Array print ( "Dimensions of Array: " ,a.ndim) # Shape of the array print ( "\nShape of Array: " ,a.shape) # Tuple x = ( 6 , 7 , 8 , 9 , 10 ) # To evaluate a Hermite series at points x print ( "\nHermite series at point" , hermite.hermval(x,a)) |
Output:
Dimensions of Array:
1
Shape of Array:
(5,)
Hermite series at point [102175. 191631. 329175. 529399. 808815.]
Example 2:
In this example, we created a 2-D array of 10 data points and further created a tuple name x, then with the use of the hermite.hermval() method we pass the required parameters to evaluate the Hermite series at a tuple at points (11,12,13,14,15) in Python.
Python3
import numpy as np from numpy.polynomial import hermite a = np.array([[ 1 , 2 , 3 , 4 , 5 ],[ 6 , 7 , 8 , 9 , 10 ]]) # Dimensions of Array print ( "Dimensions of Array: " ,a.ndim) # Shape of the array print ( "\nShape of Array: " ,a.shape) # Tuple x = ( 11 , 12 , 13 , 14 , 15 ) # To evaluate a Hermite series at points x print ( "\nHermite series at point" , hermite.hermval(x,a)) |
Output:
Dimensions of Array: 2 Shape of Array: (2, 5) array([[133., 145., 157., 169., 181.], [156., 170., 184., 198., 212.], [179., 195., 211., 227., 243.], [202., 220., 238., 256., 274.], [225., 245., 265., 285., 305.]])