
66 CHAPTER 2. APPLICATIONS OF SERIES
>
ode2:=collect(ode,x);
ode2 := (−56 c7 + n (n +1)c7 ) x
7
+(−42 c6 + n (n +1)c6 ) x
6
+ (42 c7 − 30 c5 + n (n +1)c5 ) x
5
+(n (n +1)c4 − 20 c4 +30c6 ) x
4
+(−12 c3 + n (n +1)c3 +20c5 ) x
3
+(−6 c2 +12c4 + n (n +1)c2 ) x
2
+(6c3 + n (n +1)c1 − 2 c1 ) x +2c2 + n (n +1)c0
Since ode2 represents the lhs of the Legendre equation, it must be set equal
to zero to form the complete equation. But x is arbitrary, so the coefficient of
each power of x must separately be equal to zero. A functional operator eq is
created to set the coefficient of x
m
in ode2 equal to zero.
>
eq:=m->coeff(ode2,x,m)=0:
The set of equations eq(m) is solved for the c||(m+2) for m=0 to N −2.
>
sol:=solve({seq(eq(m),m=0..N-2)},{seq(c||(m+2),m=0..N-2)}):
The solution sol is assigned, the coefficients factored and the series formed,
>
assign(sol): y:=add(factor(c||m)*xˆm,m=0..N):
and the coefficients of c0 and c1 collected in y.
>
y:=collect(y,{c||0,c||1});
y := (1 −
n (n +1)x
2
2
+
n (n − 2) (n +3)(n +1)x
4
24
−
n (n − 2) (n − 4) (n +5)(n +3)(n +1)x
6
720
)c0
+(x −
(n +2)(n − 1) x
3
6
+
(n − 1) (n − 3) (n +4)(n +2)x
5
120
−
(n − 1) (n − 3) (n − 5) (n +6)(n +4)(n +2)x
7
5040
)c1
y gives the first few term in the general series solution of Legendre’s ODE.
It consists of an even (coefficient of c0 ) and odd (coefficient of c1 ) series in
x. Noting that the denominator of the x
m
term is just m! (e.g., for m =6,
6! = (6)(5)(4)(3)(2)(1) = 720), the structure of higher order terms in the infinite
series is easy to deduce. In deriving y, Jennifer has mimicked a hand calculation.
The same result could be more easily obtained by using the series option in
the dsolve command, as Jennifer will now demonstrate. She unassigns y and
sets the order of the first term to be neglected in the series solution. Since she
has taken N =7,theorderhereis8,i.e.,termsofO(x
8
)aredroppedinthe
series. If the order is not specified, the default is to neglect terms of O(x
6
).
>
unassign(’y’): Order:=N+1;
Order := 8
Then ode is solved for y(x), subject to the initial condition y(0) = c0 and
y
(0)= c1 , using the series option in the dsolve command.
>
Y:=dsolve({ode,y(0)=c||0,D(y)(0)=c||1},y(x),series);