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
Multiply a Legendre series by an independent variable in Python
To multiply a Legendre series by an independent variable x, use the polynomial.legendre.legmulx() method in NumPy. This method takes a 1-D array of Legendre series coefficients and returns the result of multiplying the series by x.
Syntax
numpy.polynomial.legendre.legmulx(c)
Parameters
The parameter c is a 1-D array of Legendre series coefficients ordered from low to high degree. For example, [1, 2, 3] represents the series P? + 2×P? + 3×P?, where P? are Legendre polynomials.
Example
Let's create a Legendre series and multiply it by x ?
import numpy as np
from numpy.polynomial import legendre as L
# Create an array of Legendre series coefficients
c = np.array([1, 2, 3])
# Display the array
print("Our Array:")
print(c)
# Check the dimensions
print("\nDimensions:", c.ndim)
# Get the datatype
print("Datatype:", c.dtype)
# Get the shape
print("Shape:", c.shape)
# Multiply the Legendre series by x
result = L.legmulx(c)
print("\nResult after multiplying by x:")
print(result)
Our Array: [1 2 3] Dimensions: 1 Datatype: int64 Shape: (3,) Result after multiplying by x: [0.66666667 2.2 1.33333333 1.8 ]
How It Works
The legmulx() method multiplies each Legendre polynomial in the series by the independent variable x. This operation increases the degree of each term by 1, resulting in a series with one additional coefficient.
The original series [1, 2, 3] represents:
- 1×P? + 2×P? + 3×P?
After multiplication by x, we get a series of degree 3 with 4 coefficients representing the new polynomial.
Conclusion
Use numpy.polynomial.legendre.legmulx() to multiply a Legendre series by the independent variable x. The method returns a new array with coefficients representing the multiplied series, increasing the polynomial degree by one.
