Integrate a Hermite series and multiply the result by a scalar before the integration constant is added using NumPy in Python
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 numpy
from numpy.polynomial import hermite
coefficient_array = numpy.array([ 1 , 2 , 3 , 4 , 3 , 5 ])
print ( "Coefficient array: " , coefficient_array)
print ( "Dimensions: " , coefficient_array.ndim)
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 numpy
from numpy.polynomial import hermite
coefficient_array = numpy.array([[ 1 , 2 , 3 , 4 , 3 , 5 ],
[ 4 , 5 , 6 , 4 , 3 , 2 ]])
print ( "Coefficient array: " , coefficient_array)
print ( "Dimensions: " , coefficient_array.ndim)
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 ]]
Share your thoughts in the comments
Please Login to comment...