36
3 Legendre Polynomials and Legendre Functions
where x could be real or complex. The Legendre polynomials can be derived from
the generating function
1
√
1 − 2xh + h 2
=
∞
n=0
P n (x)h
n ,
(3.3)
which comes historically from the expansion of the gravitational potential 1/r, with
r the distance.
The Legendre polynomials are orthogonal on the interval −1 ≤ x ≤ +1:
1
−1
P m (x)P n (x) =
2
2n + 1
δ nm
(3.4)
and fulfill the following recurrence formula:
(n + 1)P n+1 (x) = (2n + 1)xP n (x) − nP n−1 (x) .
(3.5)
This equation, together with P 0 (x) = 1 and P 1 = x, allows to generate recursively
the Legendre polynomial coefficients for up to n ≈ 25.
The Class Legendrepoly
The Legendre polynomial coefficients up to order n can be computed with [obj,
P] = legendrepoly(n). “n” is the highest polynomial order, “obj” an object
of the class legendrepoly, with the properties, “polycoef” a table of the polynomial coefficients, “polynorm” the corresponding vector of the norm, and “polyint”
the normalization interval ([−1, +1]), and “info” here Legendre polynomial. “P” is
an array of polynomial coefficients. The rows are the coefficients of the Legendre
polynomial in descending powers of the polynomial. The SPECFUNPHYS class
legendrepoly comes with the methods of the superclass polymeth, see also
Chap. 15.
Example
>> format rat
>> [obj, P] = legendrepoly(6)
obj =
legendrepoly with properties:
polycoef: [7x7 table]
polynorm: [7x1 double]
polyint: [-1 1]
info: ’Legendre Polynomial’
P =
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
3/2
0
-1/2
3 Legendre Polynomials and Legendre Functions
where x could be real or complex. The Legendre polynomials can be derived from
the generating function
1
√
1 − 2xh + h 2
=
∞
n=0
P n (x)h
n ,
(3.3)
which comes historically from the expansion of the gravitational potential 1/r, with
r the distance.
The Legendre polynomials are orthogonal on the interval −1 ≤ x ≤ +1:
1
−1
P m (x)P n (x) =
2
2n + 1
δ nm
(3.4)
and fulfill the following recurrence formula:
(n + 1)P n+1 (x) = (2n + 1)xP n (x) − nP n−1 (x) .
(3.5)
This equation, together with P 0 (x) = 1 and P 1 = x, allows to generate recursively
the Legendre polynomial coefficients for up to n ≈ 25.
The Class Legendrepoly
The Legendre polynomial coefficients up to order n can be computed with [obj,
P] = legendrepoly(n). “n” is the highest polynomial order, “obj” an object
of the class legendrepoly, with the properties, “polycoef” a table of the polynomial coefficients, “polynorm” the corresponding vector of the norm, and “polyint”
the normalization interval ([−1, +1]), and “info” here Legendre polynomial. “P” is
an array of polynomial coefficients. The rows are the coefficients of the Legendre
polynomial in descending powers of the polynomial. The SPECFUNPHYS class
legendrepoly comes with the methods of the superclass polymeth, see also
Chap. 15.
Example
>> format rat
>> [obj, P] = legendrepoly(6)
obj =
legendrepoly with properties:
polycoef: [7x7 table]
polynorm: [7x1 double]
polyint: [-1 1]
info: ’Legendre Polynomial’
P =
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
3/2
0
-1/2
