This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / special / _multiufuncs / legendre_p

MultiUFunc

scipy.special._multiufuncs:legendre_p

source: build-install/usr/lib/python3.14/site-packages/scipy/special/_multiufuncs.py

Signature

def legendre_p(n, z, *, diff_n = 0)

Summary

Legendre polynomial of the first kind.

Parameters

n : array_like of ints

Degree of the Legendre polynomial. Must have n >= 0.

z : array_like

Input value.

diff_n : int, optional

A non-negative integer. Compute and return all derivatives up to order diff_n. Default is 0.

Returns

p : ndarray or tuple of ndarray

Legendre polynomial with diff_n derivatives.

Examples

Evaluate the Legendre polynomial :math:`P_3` at :math:`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

See also

legendre

Aliases

  • scipy.special.legendre_p

Referenced by