Open In App

Differentiate a Laguerre series and multiply each differentiation by a scalar using NumPy in Python

Last Updated : 23 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to differentiate a Laguerre series, set the derivatives, and multiply each differentiation by a scalar in Python using NumPy.

Numpy np.lagder() method

Python provides a method called lagder which is present in the Laguerre class that helps us to differentiate the Laguerre series for m times. Numpy np.lagder() method, This method is used to differentiate a Laguerre series. It accepts an array of integers which are coefficients of Laguerre series from lower order to higher order and returns a resultant array. The Laguerre series for one dimensional coefficient array [1,2,3] looks like 1*L_0+2*L_1+3*L_3 and for two dimensional coefficient array [[1,2][3,4]] looks like 1*L_0(x)*L_0(y)+2*L_0(x)*L_1(y)+3*L_1(x)*L_0(y)+4*L_1(x)*L_1(y). 

Syntax: numpy.polynomial.laguerre.lagder(coefficient_array, m=1, scl=1, axis=0)

Parameters:

  • coefficient_array: It is an array of laguerre series coefficients
  • m: It accepts a positive integer that specifies the number of times derivative can be taken.
  • scl: It is a scalar value which is multiplied with each differentiation.
  • axis: It specifies on which axis derivative is taken.

Returns: an array of laguerre series of derivatives.

Example 1

In the above code, we considered a one-dimensional array and performed differentiation on it m=2 times and at each iteration, we multiplied the result with scalar quantity 2.

Python3




# import necessary packages
import numpy as np
import numpy.polynomial.laguerre as L
  
# Create an array of coefficients
c = np.array([1, 5, 0, 4])
  
# Display the array before differentiation
print("Array before passing to lagder->", c)
  
# differentiate a Laguerre series for m times
print("After differentiation->", L.lagder(c, 2, scl=2))


Output

Array before passing to lagder-> [1 5 0 4]
After differentiation-> [32. 16.]

Example 2

In the above code, we considered a two-dimensional array and performed differentiation one time along an axis 0. The result is multiplied with a scalar value of 5 to give the final array of the Laguerre series of derivatives.

Python3




# import necessary packages
import numpy as np
import numpy.polynomial.laguerre as L
  
# Create an array of coefficients
c = np.array([[1, 2], [3, 4]])
  
# Display the array before differentiation
print("Array before passing to lagder->", c)
  
# differentiate a Laguerre series for m times
print("After differentiation->", L.lagder(c, 1, scl=5, axis=0))


Output

Array before passing to lagder-> [[1 2]
 [3 4]]
After differentiation-> [[-15. -20.]]

Example 3:

In the above code, we considered a two-dimensional array and performed differentiation one time along an axis=1. The result is multiplied with a scalar value of 5 to give the final array of the Laguerre series of derivatives.

Python3




# import necessary packages
import numpy as np
import numpy.polynomial.laguerre as L
  
# Create an array of coefficients
c = np.array([[1, 2], [3, 4]])
  
# Display the array before differentiation
print("Array before passing to lagder->", c)
  
# differentiate a Laguerre series for m times
print("After differentiation->", L.lagder(c, 1, scl=5, axis=1))


Output

Array before passing to lagder-> [[1 2]
 [3 4]]
After differentiation-> [[-10.]
 [-20.]]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads