Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to the main page for the first course APMA0330
Return to the main page for the second course APMA0340
Return to Part VII of the course APMA0340
Introduction to Linear Algebra with Mathematica
Glossary
Preface
Legendre's polynomials are eigenfunctions of a singular Sturm--Liouville problem for a second order differential equation. They are named after Adrien-Marie Legendre, who discovered them in 1782. Adrien-Marie Legendre (1752--1833) was a French mathematician. Legendre made numerous contributions to mathematics. His major work is Exercices de Calcul Intégral, published in three volumes in 1811, 1817, and 1819, where he introduced the basic properties of elliptic integrals, beta functions and gamma functions, along with their applications to mechanics.
The polynomials were named "Legendre coefficients" by the British mathematician Isaac Todhunter in honor of the French mathematician Adrien-Marie Legendre (1752–1833), who was the first to introduce and study them. Todhunter called the functions "coefficients", instead of "polynomials", because they appear as coefficients in the expansion of the generating function; Todhunter also introduced the notation Pₙ, which is still generally used.
Legendre Equation

Legendre Polynomials
A polynomial solution to the Legendre differential equation
They also admit "explicit" expression:
Example 1: We now use Mathematica to obtain the formulas for the first 11 of these polynomials. We put them in a table.
t2 = Graphics[{Text[ Style["n = 2", FontSize -> 18, FontColor -> Blue], {-0.7, 0.8}]}];
t4 = Graphics[{Orange, Text[Style["n = 4", FontSize -> 18, FontColor -> Orange], {0.2, 0.6}]}];
t6 = Graphics[{Purple, Text[Style["n = 6", FontSize -> 18, FontColor -> Purple], {-0.4, 0.5}]}];
Show[even, t2, t4, t6]
|
  |
|
| Legendre's polynomials for n = 2, 4, 6. |   | Legendre's polynomials for n = 3, 5, 7. |
First we set up a series to work with:
c[6] x^6 + O[x]^7
To see that our input is correct we type
We are going to insert this series into the differential equation
x^2 + (8 c[3] + 20 c[5]) x^3 + 30 c[6] x^4 + O[x]^5 == 0
14 c[2] + 12 c[4] == 0 && 8 c[3] + 20 c[5] == 0 && 30 c[6] == 0
Solve::svars: Equations may not give solutions for all "solve" variables. >>
Formula \eqref{EqLegendre.4} shows that Legendre's polynomials contain only even or odd powers of x, depending on parity of n. From it, we derive the numerical values:
The leading coefficient (a multiple of xn in Pn(x)) of the Legendre polynomial or order n is
The function
Simplify[D[u[t], t, t] + u[t]/4/(Sin[t])^2 + (7 + 1/2)^2 *u[t]]
Example 2:
Legendre Functions of Second Kind
Another linearly independent solution of Legendre's equation (see section ix in Part IV of tutorial I) when λ = n(n + 1) is conventionally denoted by Qn(x) and it can be determined from the formula (up to arbitrary constant multiple)
LegendreP[3, x]*Integrate[1/(1 - x^2)/(LegendreP[3, x])^2, x]
LegendreQ[3, x]
Simplify[LegendreQ[3, x] - LegendreP[3, x]*Integrate[1/(1 - x^2 )/(LegendreP[3, x])^2, x]]
Using Mathematica, we generate several Legendre polynomials of the second kind.
| n | Legendre function of the second kind | |
|---|---|---|
| n = 0 | \( \displaystyle Q_0 (x) = \frac{1}{2} \, \ln\frac{x+1}{x-1} \) | |
| n = 1 | \( \displaystyle Q_1 (x) = \frac{x}{2} \, \ln\frac{x+1}{x-1} -1 \) | |
| n = 2 | \( \displaystyle Q_2 (x) = \frac{3\,x^2 -1}{4} \, \ln\frac{x+1}{x-1} - \frac{3}{2}\,x \) | |
| n = 3 | \( \displaystyle Q_3 (x) = \frac{5\,x^3 - 3x}{4} \,\ln\frac{x+1}{x-1} - \frac{5}{2}\, x^2 + \frac{2}{3} \) | |
| n = 4 | \( \displaystyle Q_4 (x) = \frac{35\,x^4 - 30\,x^2 +3}{16} \,\ln\frac{x+1}{x-1} - \frac{35}{8}\,x^3 + \frac{55}{24}\,x \) | |
| n = 5 | \( \displaystyle Q_5 (x) = \frac{P_5 (x)}{2} \, \ln\frac{x+1}{x-1} - \frac{63}{8}\,x^4 + \frac{49}{8}\,x^2 - \frac{8}{15} \) | |
| n = 6 | \( \displaystyle Q_6 (x) = \frac{P_6 (x)}{2} \, \ln\frac{x+1}{x-1} - \frac{231}{16}\,x^5 + \frac{119}{8}\,x^3 - \frac{231}{80}\,x \) | |
| n = 7 | \( \displaystyle Q_7 (x) = \frac{P_7 (x)}{2} \, \ln\frac{x+1}{x-1} - \frac{429}{16}\,x^6 + \frac{275}{8}\,x^4 - \frac{849}{80}\,x^2 + \frac{16}{35} \) | |
| n = 8 | \( \displaystyle Q_8 (x) = \frac{P_8 (x)}{2} \,\ln\frac{x+1}{x-1} - \frac{6435}{128}\,x^7 + \frac{9867}{128}\,x^5 - \frac{4213}{128}\,x^3 + \frac{15159}{4480}\,x \) | |
| n = 9 | \( \displaystyle Q_9 (x) = \frac{P_9 (x)}{2} \,\ln\frac{x+1}{x-1} - \frac{12155}{128}\, x^8 + \frac{65065}{384}\, x^6 - \frac{11869}{128}\, x^4 + \frac{14179}{896}\, x^2 - \frac{128}{315} \) | |
| n = 10 | \( \displaystyle Q_{10} (x) = \frac{P_{10} (x)}{2} \,\ln\frac{x+1}{x-1} - \frac{46189}{256}\, x^9 + \frac{70499}{192}\, x^7 - \frac{157157}{640}\, x^5 + \frac{26741}{448}\, x^3 - \frac{61567}{16128}\, x \) |
We check with Mathematica
Simplify[(1 - x^2)*D[Q9[x], x, x] - 2*x*D[Q9[x], x] + 90*Q9[x]]
Associated Legendre Functons
The Legendre equation is a special case of the associated Legendre equation:
The associated Legendre functions of the first kind are given by Rodrigue’s formula
Mathematica has a build-in command to evaluate associated Legendre polynomials; however, it does not follow Eq.\eqref{EqLegendre.8}, but multiplies it by −1:
Associated Legendre functions of second kind
Associated Legendre functions of the second kind are defined according to the formula
=====================================================================
Legendre functions
==================================================================
Example: solve the IVP:
(4-x^2 )y'[x]+y[x]==0, y[0]==1
a[n_]:=a[n]=((n-2) a[n-2] -a[n-1])/4/n
a[0] = a0
a[1] = -a0/4
TableForm[Table[{n,a[n]},{n,0,5}]]
0 a0
1 -a0/4
2 a0/32
3 -3 a0/128
4 11 a0/2048
5 -31 a0/8192
When we apply the initial condition, we set a0=1 in the general solution.
Now we solve the initial value problem exactly:
exactsol=DSolve[{(4-x^2)y'[x]+y[x]==0,y[0]==1},y[x],x]
formula=Simplify[(2-x)^(1/4)/(2+x)^(1/4)]
????sols=Solve[sysofeqs,vars]
sersol=Series[y[x],{x,0,11}/.sols[[1]]]
Legendre's equation
Solve[(n + 2)*(n + 1)*a[n + 2] + (-n*(n - 1) - 2 n + k*(k + 1))*
a[n] == 0, a[n + 2]]
- Grigoryan, V, Partial Differential Equations, 2010, University of California, Santa Barbara.
Return to Mathematica page
Return to the main page (APMA0340)
Return to the Part 1 Matrix Algebra
Return to the Part 2 Linear Systems of Ordinary Differential Equations
Return to the Part 3 Non-linear Systems of Ordinary Differential Equations
Return to the Part 4 Numerical Methods
Return to the Part 5 Fourier Series
Return to the Part 6 Partial Differential Equations
Return to the Part 7 Special Functions