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

To integrate a Legendre series and multiply the result by a scalar before adding the integration constant, use the polynomial.legendre.legint() method in Python. This method integrates Legendre series coefficients and allows scaling at each iteration before adding integration constants.

Syntax

numpy.polynomial.legendre.legint(c, m=1, k=[], lbnd=0, scl=1, axis=0)

Parameters

  • c ? Array of Legendre series coefficients
  • m ? Order of integration (default: 1)
  • k ? Integration constant(s) (default: [])
  • lbnd ? Lower bound of integral (default: 0)
  • scl ? Scalar multiplier applied before adding integration constant (default: 1)
  • axis ? Axis over which integration is performed (default: 0)

Basic Integration Example

Let's integrate a simple Legendre series with default parameters ?

import numpy as np
from numpy.polynomial import legendre as L

# Create coefficients for Legendre series
c = np.array([1, 2, 3])
print("Original coefficients:", c)

# Basic integration
result = L.legint(c)
print("Integrated coefficients:", result)
Original coefficients: [1 2 3]
Integrated coefficients: [ 0.          0.33333333  0.4         0.6       ]

Integration with Scalar Multiplication

Now let's integrate and multiply by a scalar before adding the integration constant ?

import numpy as np
from numpy.polynomial import legendre as L

c = np.array([1, 2, 3])
print("Original coefficients:", c)

# Integration with scalar multiplication (scl = -2)
result_scaled = L.legint(c, scl=-2)
print("Result with scl=-2:", result_scaled)

# Integration with different scalar
result_scaled2 = L.legint(c, scl=0.5)
print("Result with scl=0.5:", result_scaled2)
Original coefficients: [1 2 3]
Result with scl=-2: [-0.66666667 -0.8        -1.33333333 -1.2       ]
Result with scl=0.5: [ 0.          0.16666667  0.2         0.3       ]

Multiple Integration Orders

The m parameter controls the order of integration ?

import numpy as np
from numpy.polynomial import legendre as L

c = np.array([1, 2, 3])
print("Original coefficients:", c)

# Single integration (m=1)
result1 = L.legint(c, m=1, scl=2)
print("m=1, scl=2:", result1)

# Double integration (m=2) 
result2 = L.legint(c, m=2, scl=2)
print("m=2, scl=2:", result2)
Original coefficients: [1 2 3]
m=1, scl=2: [ 0.          0.66666667  0.8         1.2       ]
m=2, scl=2: [ 0.          0.          0.22222222  0.17777778  0.34285714]

How It Works

The integration process follows these steps:

  1. Integrate the Legendre series coefficients
  2. Multiply the result by the scalar scl
  3. Add the integration constant k
  4. Repeat for m times if multiple integration is specified

The scalar multiplication happens before adding the integration constant, which affects the final coefficients significantly.

Conclusion

Use L.legint() with the scl parameter to integrate Legendre series and apply scalar multiplication before adding integration constants. This is useful for linear transformations and scaling operations in polynomial integration.

Updated on: 2026-03-26T20:59:33+05:30

218 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements