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_n derivatives.

See also

legendre

Notes

Array API Standard Support

legendre_p has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

⛔

PyTorch

✅

⛔

JAX

⚠️ no JIT

⛔

Dask

⛔

n/a

See Array API coverage for more information.

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