Evaluate Hermite series at points x when coefficients are multi-dimensional using NumPy in Python
Last Updated :
13 Jun, 2022
In this article, we will cover how to evaluate a Hermite series at points x with a multidimensional coefficient array in Python using NumPy.
Example
Input: [[11 12][13 14]]
Output: [[37. 63.][40. 68.]]
Explanation: Hermite series at points x.
NumPy.polynomial.hermite.hermval method
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: polynomial.hermite.hermval(x,c, tensor)
Parameter:
- x: array_like
- c: Array of coefficient
- tensor: boolean(optional).
Return: An Hermite series at points x.
Example 1:
In the first example, let us consider a 2D array and evaluate a Hermite series at point x. Import the necessary packages and pass the appropriate parameters as shown.
Python3
import numpy as np
from numpy.polynomial import hermite
# coefficient array
c = np.array([[11, 12], [13, 14]])
print(f'The coefficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
# evaluating multidimensal array of hermiteseries
res = hermite.hermval([1, 2], c)
# resultant array
print(f'Resultant series ---> {res}')
Output:
The coefficient array is
[[11 12]
[13 14]]
The shape of the array is (2, 2)
The dimension of the array is 2D
The datatype of the array is int32
Resultant series --->
[[37. 63.]
[40. 68.]]
Example 2:
In the second example, let us consider a 3D array and evaluate a Hermite series at point x. Import the necessary packages and pass the appropriate parameters as shown
Python3
import numpy as np
from numpy.polynomial import hermite
# coefficient array
c = np.arange(27).reshape(3, 3, 3)
print(f'The coefficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
# evaluating multidimensal array of hermiteseries
res = hermite.hermval([17, 22], c)
# resultant array
print(f'Resultant series ---> {res}')
Output:
The coefficient array is
[[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]
[[18 19 20]
[21 22 23]
[24 25 26]]]
The shape of the array is (3, 3, 3)
The dimension of the array is 3D
The datatype of the array is int32
Resultant series --->
[[[21078. 35208.]
[22267. 37187.]
[23456. 39166.]]
[[24645. 41145.]
[25834. 43124.]
[27023. 45103.]]
[[28212. 47082.]
[29401. 49061.]
[30590. 51040.]]]
Similar Reads
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
2 min read
Evaluate a 2-D Hermite_e series at points (x,y) with 3D array of coefficient using NumPy in Python In this article, we will cover how to evaluate a 2-D Hermite_e series at points (x,y) with a 3D array of coefficients using NumPy in Python. np.polynomial.hermite_e.hermeval2d method The np.polynomial.hermite_e.hermeval2d from the NumPy library is used to Evaluate a 2-D Hermite_e series at points(x,
3 min read
Evaluate a 2-D Hermite series at points (x,y) with 3D array of coefficient using NumPy in Python In this article, we'll look at how to evaluate a 2-dimensional Hermite series using NumPy in Python at an array of points x, and y with the 3-dimensional array. np.hermval2d method We are using the hermite.hermval2d() function from the Numpy module to evaluate a 2D Hermite series at locations (x, y)
2 min read
Evaluate a Hermite_e series at points x with multidimensional coefficient array in Python In this article, we will cover how to evaluate a Hermite_e series at points x with a multidimensional coefficient array in Python using NumPy. ExampleInput: [[0 1] [2 3]] Output: [[ 6. 2.] [10. 4.]] Explanation: Hermite_e series at input points.hermite_e.hermeval method To evaluate a Hermite series
2 min read
Evaluate a Hermite_e series at list of points x using NumPy in Python In this article, we will be looking toward the approach to evaluating a Hermite_e series at a list of points x using Python and NumPy. Example: List: [6,7,8,9,10] Result: [102175. 191631. 329175. 529399. 808815.] Explanation: Hermite_e series at points x.NumPy.polynomial.hermite_e.hermeval() method
3 min read
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 param
3 min read