Skip to content
Related Articles

Related Articles

Integrate a Hermite series and multiply the result by a scalar before the integration constant is added using NumPy in Python

View Discussion
Improve Article
Save Article
  • Last Updated : 03 Jun, 2022

In this article, we will see how to integrate a Hermite series and multiply the result by a scalar before the integration constant is added in Python.

hermite.hermint method    

Hermite nodes are utilised as matching points for optimising polynomial interpolation, Hermite polynomials are important in approximation theory. NumPy has a function called hermite.hermint() that can be used to integrate the Hermite series in a specific order. It will require two parameters: c, which is an array, and scl, which is a scalar that will be multiplied by the integrated Hermite series before the integration constant is added.

Syntax: hermite.hermint(c,scl)

Parameter:

  • c: an array
  • scl: A scalar value

Return: Hermite series coefficients of the integral.

Example 1

In this example, we will create a one-dimensional NumPy coefficient array with 6 elements and integrate the Hermite series and multiply the result by a scalar with the value -2  before the integration constant.

Python3




# import the numpy module
import numpy
  
# import hermite
from numpy.polynomial import hermite
  
# Create an array of hermite series
# coefficients with 6 elements
coefficient_array = numpy.array([1, 2, 3, 4, 3, 5])
  
# display array
print("Coefficient array: ", coefficient_array)
  
# display the dimensions
print("Dimensions: ", coefficient_array.ndim)
  
# integrate hermite series with scale=2
print(    hermite.hermint(coefficient_array, scl=-2))

Output:

Coefficient array:  [1 2 3 4 3 5]

Dimensions:  1

[-90.          -1.          -1.          -1.          -1.

  -0.6         -0.83333333]   

Example 2

In this example, we will create a two-dimensional NumPy coefficient array with 6 elements each and integrate the Hermite series and multiply the result by a scalar with value -1 before the integration constant.

Python3




# import the numpy module
import numpy
  
# import hermite
from numpy.polynomial import hermite
  
# Create an 2d array of hermite series
# coefficients with 6 elements each
coefficient_array = numpy.array([[1, 2, 3, 4, 3, 5], 
                                 [4, 5, 6, 4, 3, 2]])
  
# display array
print("Coefficient array: ", coefficient_array)
  
# display the dimensions
print("Dimensions: ", coefficient_array.ndim)
  
# integrate hermite series with scale=-1
print(    hermite.hermint(coefficient_array, scl=-1))

Output:

Coefficient array:  [[1 2 3 4 3 5]
 [4 5 6 4 3 2]]
Dimensions:  2
[[-2.   -2.5  -3.   -2.   -1.5  -1.  ]
 [-0.5  -1.   -1.5  -2.   -1.5  -2.5 ]
 [-1.   -1.25 -1.5  -1.   -0.75 -0.5 ]]

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!