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 over axis 1 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. The scaling factor is for use in a linear change of variable.
Syntax
numpy.polynomial.laguerre.lagint(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Parameters
- c ? Array of Laguerre series coefficients. If c is 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
- lbnd ? Lower bound of the integral (Default: 0)
- scl ? Scalar multiplied after each integration before adding the constant (Default: 1)
- axis ? Axis over which the integral is taken (Default: 0)
Example
Let's integrate a Laguerre series over axis 1 using a multidimensional array ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2, 2)
# 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 a Laguerre series over axis 1
print("\nResult...\n", L.lagint(c, axis=1))
Our Array... [[0 1] [2 3]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result... [[ 0. 1. -1.] [ 2. 1. -3.]]
How It Works
When integrating over axis 1, each row is treated as a separate Laguerre series. The integration adds one degree to each polynomial, expanding the shape from (2, 2) to (2, 3). The Laguerre integration formula transforms the coefficients according to the Laguerre polynomial properties.
Example with Different Parameters
Here's how to use different integration parameters ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create coefficients
c = np.array([[1, 2], [3, 4]])
# Integration with different parameters
result1 = L.lagint(c, m=2, axis=1) # Second order integration
result2 = L.lagint(c, k=[1, 2], axis=1) # With integration constants
result3 = L.lagint(c, scl=2, axis=1) # With scaling factor
print("Original array:")
print(c)
print("\nSecond order integration:")
print(result1)
print("\nWith integration constants [1, 2]:")
print(result2)
print("\nWith scaling factor 2:")
print(result3)
Original array: [[1 2] [3 4]] Second order integration: [[ 1. 1. -3. 2.] [ 3. -1. -7. 4.]] With integration constants [1, 2]: [[ 1. 3. -2.] [ 5. 1. -4.]] With scaling factor 2: [[ 2. 4. -4.] [ 6. 2. -8.]]
Conclusion
The laguerre.lagint() method provides flexible Laguerre series integration over specified axes. Use the axis parameter to control integration direction, and adjust m, k, and scl parameters for different integration requirements.
