Differentiate a Legendre series and set the derivatives using NumPy in Python
Last Updated :
03 Jun, 2022
In this article, we will cover how to differentiate a Legendre series and set the derivatives using NumPy in Python.
numpy.polynomial.legendre.legder
The numpy.polynomial.legendre.legder() method from the NumPy library is used to differentiate a Legendre series and set the derivatives in Python. The Legendre series coefficients c differed m times along the axis are returned. The result is multiplied by scl at each iteration . The c argument is an array of coefficients ranging in degree from low to high along each axis, such as [4,3,2]. indicates the series 4 *L 0 + 3*L 1 + 2*L 2, whereas [[2,1],[2,1]] indicates 2 *L 0(x)*L 0(y) + 2*L 1(x)*L 0(y) + 1*L 0(x)*L 1(y) + 1*L 1(x)*L 1(y) .If axis=0 is x and axis=1 is y.
Syntax: polynomial.legendre.legder(c, m=1, scl=1, axis=0)
Parameters:
- c: array like object.
- m: int , optional. The total number of derivatives taken must not be negative. It is set to 1 by default.
- axis: optional value, int. The axis on which the derivative is computed. It is set to 0 by default.
Returns: Legendre series of the derivative.
Example 1:
Here, we will create a NumPy array and use polynomial.legendre.legder() to differentiate a Legendre series where the series is an array of coefficients. The shape of the array is found by the .shape attribute, the dimension of the array is found by .ndim attribute, and the data type of the array is .dtype attribute.
Python3
# import packages
import numpy as np
from numpy.polynomial import legendre as L
# array of coefficients
array = np.array([10,20,30,40])
print(array)
# shape of the array is
print("Shape of the array is : ",array.shape)
# dimension of the array
print("The dimension of the array is : ",array.ndim)
# differenciate Legendre series
print(L.legder(array,2))
Output:
[10 20 30 40]
Shape of the array is : (4,)
The dimension of the array is : 1
[ 90. 600.]
Example 2:
In this example, a 2d array of Coefficients is given as input and the axis parameter is given a value of '1' which specifies that the derivative is computed on the columns.
Python3
# import packages
import numpy as np
from numpy.polynomial import legendre as L
# array of coefficients
array = np.array([[10,20],[30,40]])
print(array)
# shape of the array is
print("Shape of the array is : ",array.shape)
# dimension of the array
print("The dimension of the array is : ",array.ndim)
# differenciate Legendre series
print(L.legder(array,1,axis =1))
Output:
[[10 20]
[30 40]]
Shape of the array is : (2, 2)
The dimension of the array is : 2
[[20.]
[40.]]
Similar Reads
Differentiate a Hermite_e series and set the derivatives using NumPy in Python In this article, we will cover how to differentiate a Hermite_e series and set derivatives in Python using NumPy. np.polynomial.hermite_e.hermeder method: To Differentiate a Hermite series in python we use the NumPy.polynomial.hermite_e.hermeder() method which is used to return the c differentiated
3 min read
Differentiate a Hermite series and set the derivatives in Python In this article, we are going to cover how to differentiate a Hermite series and set the derivatives in Python using NumPy. numpy.polynomial.hermite.hermder methodTo differentiate the Hermite series python provides a method called hermite.hermder which is present in the NumPy package. This method ac
3 min read
Differentiate a Legendre series using NumPy in Python In this article, we will cover how to differentiate a Legendre series in Python using NumPy. legendre.legder method In python, the Legendre module provides many functions like legder to perform arithmetic, and calculus operations on the Legendre series. It is one of the functions provided by the Leg
3 min read
Differentiate a polynomial and set the derivatives in Python-NumPy In this article, we will cover how to differentiate a polynomial and set the derivatives in Python. numpy.polynomial.polynomial.polyder method The Numpy library provides the numpy.polynomial.polynomial.polyder() method to differentiate a polynomial and set the derivatives. The polynomial coefficient
3 min read
Differentiate a Chebyshev series using NumPy in Python In this article, we will cover how to integrate a Chebyshev series and set the integration constant in Python using NumPy. chebyshev.chebder method The Chebyshev series has polynomials with the largest possible leading coefficient, whose absolute value on the interval [â1, 1] is bounded by 1. They a
3 min read
Integrate Legendre series and set the lower bound of the integral using NumPy in Python In this article, we will see how to integrate a Legendre series and set the lower bound of the integral in Python using NumPy. To perform Legendre integration, NumPy provides a function called legendre.legint which can be used to integrate Legendre series. Syntax: legendre.legint(c, lbnd=0, scl=1, a
3 min read