legendreP

Legendre polynomial.

Category: Mathematics > Polynomials

Syntax

P = legendreP(n, x)

Evaluates the Legendre polynomial of degree n at x.

Description

P_n(x) is orthogonal on [-1, 1] with weight 1. It satisfies (n + 1)*P_(n+1) = (2*n + 1)*x*P_n - n*P_(n-1) with P_0 = 1 and P_1 = x, and it takes the values P_n(1) = 1 and P_n(-1) = (-1)^n.

It appears in the multipole expansion of potentials and in Gauss-Legendre quadrature, whose nodes are its zeros. This is the ordinary polynomial; the associated Legendre functions are a separate family.

Input arguments

n
Degree, a nonnegative integer or a symbolic variable.
x
Point(s) of evaluation, or a symbolic variable to get the polynomial.

Output arguments

P
Numbers with the size of x, or a symbolic polynomial.

Example

Polynomials and exact values

syms x
legendreP(0:3, x)
legendreP(3, sym(1)/2)
Output
ans = 
[1, x, (3*x^2)/2 - 1/2, (5*x^3)/2 - (3*x)/2]
ans = -7/16

See also

legendre chebyshevT jacobiP gegenbauerC