Saturday, December 28, 2024
Google search engine
HomeLanguagesEvaluate a Hermite_e series at points x in using NumPy Python

Evaluate a Hermite_e series at points x in using NumPy Python

In this article, we will cover how to evaluate a Hermite_e series at points x using NumPy in Python.

numpy.polynomial.hermite.hermval

The numpy.polynomial.hermite.hermval() method from the NumPy library is used to evaluate a Hermite series at points x. If the parameter x is a tuple or a list, it is turned into an array otherwise, it is regarded as 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: numpy.polynomial.hermite.hermval

Parameters:

  • x: array like object. 
  • c: Array of coefficients 
  • tensor: optional value, boolean type.

Returns:  ndarray of Hermite_e series

Example 1:

The NumPy package is imported. An array is created which represents coefficients of the Hermite series. polynomial.hermite.hermval() is used to evaluate a Hermite series at point x. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. In this example, x is a scalar.

Python3




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)
  
# evaluating a hermite series at points x
print(H.hermval(1,array))


Output:

[5 6 7 8]
Shape of the array is :  (4,)
The dimension of the array is :  1
-1.0

Example 2:

The NumPy package is imported. An array is created using NumPy, which represents coefficients of the Hermite series. polynomial.hermite.hermval() is used to evaluate a Hermite series at a point x, where x is [1,2]. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. x is a list. 

Python3




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)
  
# evaluating a hermite series at points x
print(H.hermval([1,2],array))


Output:

[5 6 7 8]
Shape of the array is :  (4,)
The dimension of the array is :  1
[ -1. 447.]

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