scipy.special.legendre_p#
- scipy.special.legendre_p(n, z, *, diff_n=0) = <scipy.special._multiufuncs.MultiUFunc object>[source]#
Legendre polynomial of the first kind.
- Parameters:
- narray_like of ints
Degree of the Legendre polynomial. Must have
n >= 0.- zarray_like
Input value.
- diff_nint, optional
A non-negative integer. Compute and return all derivatives up to order
diff_n. Default is 0.
- Returns:
- pndarray or tuple of ndarray
Legendre polynomial with
diff_nderivatives.
See also
References
[1]Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
Examples
Evaluate the Legendre polynomial \(P_3\) at \(z = 0.5\):
>>> import numpy as np >>> from scipy.special import legendre_p >>> np.allclose(legendre_p(3, 0.5), -0.4375) True
Compute the value and first derivative with respect to
z:>>> p, dp = legendre_p(3, 0.5, diff_n=1) >>> np.allclose([p, dp], [-0.4375, 0.375]) True