Saturday, December 28, 2024
Google search engine
HomeLanguagesEvaluate a Hermite_e series at points x with multidimensional coefficient array in...

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.

Example

Input: [[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 at points x with a multidimensional coefficient array, NumPy provides a function called hermite_e.hermeval(). It takes two parameters x and c. whereas x is a tuple or list and c is an array of coefficients. This method is available in the hermite_e module in python, it returns a Hermite_e series at the given input points, Below is the syntax of the hermeval method.

Syntax: hermite_e.hermeval(x, c, tensor)

Parameter:

  • x: a list or tuple
  • c: an array of coefficients ordered
  • tensor: boolean, optional

Return: Hermite_e series at points x

Example 1:

In this example, we are creating a coefficient of a multi-dimensional array with 5 elements and displaying the shape and dimensions of the array. After that, we are evaluating the Hermite_e series at points [4,1].

Python3




# import the numpy module
import numpy
  
# import hermite_se
from numpy.polynomial import hermite_e
  
# create array of coefficients with 5 elements each
coefficients_data = numpy.array([[1, 2, 3, 4, 5], 
                                 [3, 4, 2, 6, 7]])
  
# Display the coefficients
print(coefficients_data)
  
# get the shape
print(f"\nShape of an array: {coefficients_data.shape}")
  
# get the dimensions
print(f"Dimension: {coefficients_data.ndim}")
  
# Evaluate a Hermite_e series at points - [4,1]
print("\nHermite_e series", hermite_e.hermeval(
  [4, 1], coefficients_data))


Output:

[[1 2 3 4 5]
 [3 4 2 6 7]]

Shape of an array: (2, 5)
Dimension: 2

Hermite_e series [[13.  4.]
 [18.  6.]
 [11.  5.]
 [28. 10.]
 [33. 12.]]

Example 2:

In this example, we are creating a coefficient of a multi-dimensional array with NumPy of shape 2×2 and displaying the shape and dimensions of the array. After that, we are evaluating the Hermite_e series at points [3,1].

Python3




# import the numpy module
import numpy
  
# import hermite_se
from numpy.polynomial import hermite_e 
  
# create array of coefficients with 5 elements each
coefficients_data = np.arange(4).reshape(2,2)
  
# Display the coefficients
print(coefficients_data)
  
# get the shape
print(f"\nShape of an array: {coefficients_data.shape}")
  
# get the dimensions
print(f"Dimension: {coefficients_data.ndim}")
  
h = [3,1]
  
# Evaluate a Hermite_e series at points - [3,1]
print("\nHermite_e series", hermite_e.hermeval(
  h,coefficients_data))


Output:

[[0 1]
 [2 3]]

Shape of an array: (2, 2)
Dimension: 2

Hermite_e series [[ 6.  2.]
 [10.  4.]]

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