legendre

Associated Legendre functions of degree n.

Category: Mathematics > Elementary Math

Syntax

P = legendre(n, X)

Returns the functions P(n, m)(x) for orders m = 0 to n at every point of X.

P = legendre(n, X, normalization)

Chooses the normalization: 'unnorm' (default), 'sch' (Schmidt semi-normalized) or 'norm' (fully normalized).

Description

Row m+1 of the result holds the associated Legendre function of degree n and order m. The first row (m = 0) is the ordinary Legendre polynomial. These functions appear in the angular part of solutions of Laplace's equation in spherical coordinates, hence in gravity, geomagnetism and the hydrogen atom.

In the unnormalized form the Condon-Shortley phase (-1)^m is included, which is why the odd orders come out negative for positive x in the example below.

Input arguments

n
Degree: a nonnegative integer scalar.
X
Real values in the interval from -1 to 1.
normalization
'unnorm', 'sch' or 'norm'.

Output arguments

P
Array with n+1 rows (the orders m = 0, 1, ..., n) and one column per element of X.

Example

Degree 2 at three points

legendre(2, [0 0.5 1])
legendre(2, 0.5, 'norm')
Output
ans = 3×3

   -0.5000   -0.1250    1.0000
         0   -1.2990         0
    3.0000    2.2500         0
ans = 3×1

   -0.1976
    0.8385
    0.7262

See also

polyval gamma ellipke besselj