Skip to content
Related Articles

Related Articles

Raise a Hermite series to a power in Python

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 21 Apr, 2022

The Hermite polynomials, like the other classical orthogonal polynomials, can be defined from a variety of starting locations. In this article let’s see how to Raise a Hermite series to a power in Python. The NumPy package provides us polynomial.hermite.hermpow() method to raise a Hermite series.

Syntax: polynomial.hermite.hermpow(c, pow, maxpower=16)

Parameters:

  • c: The coefficients of the Hermite series are arranged in a 1-D array from low to high.
  • pow: The series’ power will be increased according to the number specified.
  • maxpower: by default it is 16. Maximum power is permitted. This is mostly to prevent the series from becoming unmanageable in size. 

Returns: an array of raised hermite series is returned.

Example 1:

The NumPy package is imported. An array is created which represents coefficients of the hermite series. polynomial.hermite.hermpow() is used to raise the Hermite series, in the below example , 2 is given as the value for the pow parameter, it raises the Hermite series by power 2. 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
  
# Creating an array
array = np.array([3,1,4])
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)
  
# raising hermite series to the power 2
print(H.hermpow(array,2))


Output:

[3 1 4]
Shape of the array is :  (3,)
The dimension of the array is :  1
Datatype of our Array is :  int64
[139.  38. 153.   8.  16.]

Example 2:

In this example a new parameter maxpower is returned, it represents the maximum permitted power. we cannot give a value to pow parameter which is greater than the maxpower, else a ValueError gets raised, saying “power is too large”. 

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite as H
  
# Creating an array
array = np.array([3,1,4])
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)
  
# raising hermite series to the power 2
print(H.hermpow(array,6,maxpower=5))


Output:

[3 1 4]
Shape of the array is :  (3,)
The dimension of the array is :  1
Datatype of our Array is :  int64
 raise ValueError("Power is too large")
ValueError: Power is too large

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!