Skip to main content
`Ctrl`+`K`

# scipy.special.legendre_p

scipy.special.legendre_p(n, z, *, diff_n=0) = <scipy.special._multiufuncs.MultiUFunc object>

  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.

  See also

  `legendre`

  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