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 in Python
To differentiate a Laguerre series, use the laguerre.lagder() method in Python. The method returns the Laguerre series coefficients differentiated m times along the specified axis. At each iteration, the result is multiplied by scl.
The argument c is an array of coefficients from low to high degree along each axis. For example, [1,2,3] represents the series 1*L_0 + 2*L_1 + 3*L_2, while [[1,2],[1,2]] 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. If multidimensional, different axes correspond to different variables.
- m: Number of derivatives taken, must be non-negative (Default: 1)
- scl: Scalar multiplier for each differentiation. Final result is multiplied by scl**m (Default: 1)
- axis: Axis over which the derivative is taken (Default: 0)
Example
import numpy as np
from numpy.polynomial import laguerre as L
# Create an array of coefficients
c = np.array([1, 2, 3, 4])
# 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)
# To differentiate a Laguerre series, use the laguerre.lagder() method
print("\nResult...\n", L.lagder(c))
Our Array... [1 2 3 4] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) Result... [-9. -7. -4.]
Multiple Derivatives
You can take multiple derivatives by specifying the m parameter:
import numpy as np
from numpy.polynomial import laguerre as L
c = np.array([1, 2, 3, 4])
# First derivative
print("First derivative:", L.lagder(c, m=1))
# Second derivative
print("Second derivative:", L.lagder(c, m=2))
First derivative: [-9. -7. -4.] Second derivative: [14. 12.]
Conclusion
The laguerre.lagder() method efficiently differentiates Laguerre series by taking derivatives of the coefficient array. Use the m parameter to control the number of derivatives and scl for scaling operations.
