Integrate a Laguerre series and multiply the result by a scalar before the integration constant is added in Python
Last Updated :
03 Jun, 2022
In this article, we will see how to integrate a Laguerre series and multiply the result by a scalar before the integration constant is added in python.
laguerre.lagint method
Laguerre polynomials arise in quantum theory because the Laguerre nodes are used as matching points for optimizing polynomial interpolation. To perform Hermite Integration, NumPy provides a function called laguerre.lagint() method, which is used to integrate the Hermite series with a given order. It will take two parameters, the first is c which takes an array and, the second is scl which is a scalar that is multiplied with the integrated laguerre series before the integration constant is added.
Syntax: laguerre.lagint(c,scl)
Parameter:
- c: an array
- scl: A scalar value
Return: Laguerre 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 Laguerre series and multiply the result by a scalar with the value -2 before the integration constant.
Python3
import numpy
from numpy.polynomial import laguerre
coefficient_array = numpy.array([ 1 , 2 , 3 , 4 , 3 , 5 ])
print ( "Coefficient array: " , coefficient_array)
print ( "Dimensions: " , coefficient_array.ndim)
print ( laguerre.lagint(coefficient_array, scl = - 2 ))
|
Output:
Coefficient array: [1 2 3 4 3 5]
Dimensions: 1
[-2. -2. -2. -2. 2. -4. 10.]
Example 2
In this example, we will create a two-dimensional NumPy coefficient array with 6 elements each and integrate the Laguerre series and multiply the result by a scalar with value -1 before the integration constant.
Python3
import numpy
from numpy.polynomial import laguerre
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 ( laguerre.lagint(coefficient_array, scl = - 1 ))
|
Output:
Coefficient array: [[1 2 3 4 3 5]
[4 5 6 4 3 2]]
Dimensions: 2
[[-1. -2. -3. -4. -3. -5.]
[-3. -3. -3. 0. 0. 3.]
[ 4. 5. 6. 4. 3. 2.]]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...