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
Differentiate a Laguerre series with multidimensional coefficients over specific axis in Python
To differentiate a Laguerre series with multidimensional coefficients, use the laguerre.lagder() method in Python. This method returns the Laguerre series coefficients differentiated m times along a specified axis. At each iteration, the result is multiplied by a scalar value.
The coefficient array represents Laguerre polynomials where [1,2,3] represents the series 1*L_0 + 2*L_1 + 3*L_2. For multidimensional arrays like [[1,2],[1,2]], it represents 1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y) if axis=0 is x and axis=1 is y.
Syntax
laguerre.lagder(c, m=1, scl=1, axis=0)
Parameters
c: Array of Laguerre series coefficients. For multidimensional arrays, different axes correspond to different variables.
m: Number of derivatives to take (must be non-negative, default: 1).
scl: Scalar multiplier for each differentiation (default: 1). Final result is multiplied by scl**m.
axis: Axis over which the derivative is taken (default: 0).
Example
Let's differentiate a Laguerre series with a 2D coefficient array along different axes ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)
print("Coefficient Array:")
print(c)
print(f"Shape: {c.shape}")
# Differentiate along axis 0
result_axis0 = L.lagder(c, axis=0)
print("\nDifferentiation along axis 0:")
print(result_axis0)
# Differentiate along axis 1
result_axis1 = L.lagder(c, axis=1)
print("\nDifferentiation along axis 1:")
print(result_axis1)
Coefficient Array: [[0 1] [2 3]] Shape: (2, 2) Differentiation along axis 0: [[-2. -2.]] Differentiation along axis 1: [[-1.] [-3.]]
Multiple Derivatives
You can take multiple derivatives by setting the m parameter ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create a larger coefficient array
c = np.arange(12).reshape(3,4)
print("Original coefficients:")
print(c)
# Take second derivative along axis 1
result = L.lagder(c, m=2, axis=1)
print("\nSecond derivative along axis 1:")
print(result)
Original coefficients: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] Second derivative along axis 1: [[-2. -2.] [-2. -2.] [-2. -2.]]
Using Scale Factor
The scl parameter multiplies each differentiation step ?
import numpy as np
from numpy.polynomial import laguerre as L
c = np.array([[1, 2, 3], [4, 5, 6]])
print("Original coefficients:")
print(c)
# Differentiate with scale factor
result = L.lagder(c, m=1, scl=2, axis=1)
print("\nDifferentiation with scl=2 along axis 1:")
print(result)
Original coefficients: [[1 2 3] [4 5 6]] Differentiation with scl=2 along axis 1: [[-2. -2.] [-2. -2.]]
Comparison
| Parameter | Effect | Example |
|---|---|---|
axis=0 |
Differentiates along rows | Reduces first dimension |
axis=1 |
Differentiates along columns | Reduces second dimension |
m=2 |
Takes second derivative | Further reduces dimension |
scl=2 |
Scales result by 2^m | Multiplies final result |
Conclusion
The lagder() method efficiently differentiates multidimensional Laguerre series along specified axes. Use the axis parameter to control differentiation direction and m for multiple derivatives.
