Friday, December 27, 2024
Google search engine
HomeLanguagesEvaluate a 2-D Hermite_e series at points (x,y) using NumPy in Python

Evaluate a 2-D Hermite_e series at points (x,y) using NumPy in Python

In this article, we will cover how to evaluate a 2-D Hermite_e series at points (x,y) in Python.

polynomial.hermite.hermval2d

The numpy.polynomial.hermite.hermval2d() from the NumPy library is used to Evaluate a 2-D Hermite_e series at points(x,y) in Python. If the parameters x and y are tuples or lists, they are converted to arrays otherwise they are treated as scalars and must have the same shape after conversion. In either case, x and y or their elements must support multiplication and addition with themselves as well as with the elements of c. If c is a one-dimensional array, a one is implicitly appended to its shape to make it two-dimensional. The final shape will be c.shape[2:] + x.shape.

 Syntax: polynomial.hermite.hermval2d(x, y, c)

Parameters : 

  • x , y: array like compatible objects.
  • c: array like object.

Returns : The values of the two-dimensional polynomial at coordinates formed by corresponding pairs of x and y values.

Example 1:

The NumPy package is imported. An array is created which represents coefficients of the Hermite series. polynomial.hermite.hermval2d(x, y, c) is used to evaluate a 2-D Hermite series, in the below example, arrays are given for x and y parameters which represent multiple points. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. 

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite as H
  
# array of coefficients
array = np.array([[5,6],[7,8]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",array.dtype)
  
# evaluating a 2-d hermite series at point(x,y)
print(H.hermval2d([1,1],[2,2],array))


Output:

[[5 6]
 [7 8]]
Shape of the array is :  (2, 2)
The dimension of the array is :  2
Datatype of our Array is :  int64
[107. 107.]

Example 2:

In this example, scalars are given as x and y parameters which represent a single point and the 2-d Hermite series is evaluated at that point.

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite as H
  
# array of coefficients
array = np.array([[5,6],[7,8]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",array.dtype)
  
# evaluating a 2-d hermite series at point(x,y)
print(H.hermval2d(1,2,array))


Output:

[[5 6]
 [7 8]]
Shape of the array is :  (2, 2)
The dimension of the array is :  2
Datatype of our Array is :  int64
107.0

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments