NumPy.polynomial.hermite.hermgrid3d method
Hermite polynomials are significant in approximation theory because the Hermite nodes are used as matching points for optimizing polynomial interpolation. To perform Hermite differentiation, NumPy provides a function called hermite.hermgrid3d which can be used to evaluate the cartesian product of the 3D Hermite series. This function converts the parameters x, y, and z to array only if they are tuples or a list, otherwise, it is left unchanged and, if it is not an array, it is treated as a scalar.
Syntax: polynomial.hermite.hermgrid3d(x, y, z, c)
Parameters:
- x,y,z: array_like
- c: array of coefficients
Returns: Two dimensional polynomials at points as cartesian products of x and y.
Example 1:
In the first example. let us consider a 4D array c of size 32. Let us consider a 3D series [1,2],[1,2],[1,2] to evaluate against the 4D array. Import the necessary packages as shown and pass the appropriate parameters as shown below.
Python3
import numpy as np from numpy.polynomial import hermite # co.efficient array c = np.arange( 32 ).reshape( 2 , 2 , 4 , 2 ) print (f 'The co.efficient 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 4d co.eff array with a 3d hermite series res = hermite.hermgrid3d([ 1 , 2 ], [ 1 , 2 ], [ 1 , 2 ], c) # resultant array print (f 'Resultant series ---> {res}' ) |
Output:
The co.efficient 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 27] [28 29] [30 31]]]] The shape of the array is (2, 2, 4, 2) The dimension of the array is 4D The datatype of the array is int64 Resultant series ---> [[[[3.6000e+01 1.1232e+04] [7.6000e+01 1.9664e+04]] [[9.2000e+01 2.0608e+04] [1.8000e+02 3.5920e+04]]] [[[4.5000e+01 1.1763e+04] [9.1000e+01 2.0549e+04]] [[1.0700e+02 2.1493e+04] [2.0500e+02 3.7395e+04]]]]
Example 2:
In this example, we are using a 1-D array to evaluate a 3-D Hermite series on the Cartesian product series.
Python3
# import packages import numpy as np from numpy.polynomial import hermite # array of coefficients c = np.array([ 2 , 2 , 3 ]) print (c) # shape of the array is print ( "Shape of the array is : " ,c.shape) # dimension of the array print ( "The dimension of the array is : " ,c.ndim) # Datatype of the array print ( "Datatype of our Array is : " ,c.dtype) #evaluating hermite series print (hermite.hermgrid3d([ 1 , 2 ],[ 3 , 4 ],[ 5 , 6 ],c)) |
Output:
[2 2 3] Shape of the array is : (3,) The dimension of the array is : 1 Datatype of our Array is : int64 [4604. 5460.]
Contact Us