Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Integrate a Laguerre series and set the Integration constant in Python
To integrate a Laguerre series, use the laguerre.lagint() method in Python. The method returns the Laguerre series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added.
Syntax
numpy.polynomial.laguerre.lagint(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Parameters
The function accepts the following parameters ?
- c ? Array of Laguerre series coefficients. If multidimensional, different axes correspond to different variables
- m ? Order of integration, must be positive (Default: 1)
-
k ? Integration constant(s). If
k == [](default), all constants are set to zero. Form == 1, a single scalar can be given - lbnd ? Lower bound of the integral (Default: 0)
- scl ? Scalar multiplier applied after each integration (Default: 1)
- axis ? Axis over which the integral is taken (Default: 0)
Example
Let's create a Laguerre series and integrate it with different integration constants ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create an array of coefficients
c = np.array([1, 2, 3])
# Display the array
print("Our Array...\n", c)
# Check the Dimensions
print("\nDimensions of our Array...\n", c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n", c.dtype)
# Get the Shape
print("\nShape of our Array object...\n", c.shape)
# Integrate with integration constant k = 3
print("\nResult with k=3...\n", L.lagint(c, k=3))
Our Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result with k=3... [ 4. 1. 1. -3.]
Integration with Different Constants
Let's see how different integration constants affect the result ?
import numpy as np
from numpy.polynomial import laguerre as L
c = np.array([1, 2, 3])
# Default integration (k=0)
print("Default integration (k=0):", L.lagint(c))
# Integration with k=5
print("Integration with k=5:", L.lagint(c, k=5))
# Integration with k=-2
print("Integration with k=-2:", L.lagint(c, k=-2))
Default integration (k=0): [ 1. 1. 1. -3.] Integration with k=5: [ 6. 1. 1. -3.] Integration with k=-2: [-1. 1. 1. -3.]
Multiple Integration
You can also perform multiple integrations by setting the m parameter ?
import numpy as np
from numpy.polynomial import laguerre as L
c = np.array([1, 2, 3])
# Single integration
print("Single integration:", L.lagint(c, m=1, k=1))
# Double integration with multiple constants
print("Double integration:", L.lagint(c, m=2, k=[1, 2]))
Single integration: [ 2. 1. 1. -3.] Double integration: [ 3. 2. 0.5 0.5 -0.75]
Conclusion
The laguerre.lagint() method integrates Laguerre series with customizable integration constants. The integration constant k directly affects the first coefficient of the result, while higher-order coefficients depend on the original series.
