16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

128 CHAPTER 3. LINEAR ODE MODELS<br />

series solution to order n as long as the percentage error in the previous order<br />

is above 1 percent.<br />

> for n from 1 to 50 while percent[n-1]>1 do<br />

The order of the series is taken to be n. The error in the series is of order x n ,<br />

terms of this order and larger being neglected. If the order is not speci¯ed, the<br />

default order is 6.<br />

> Order:=n:<br />

The di®erential equation is solved for y(x), subject to the initial condition,<br />

with the series option included. The dsolve command uses several methods<br />

when trying to ¯nd a series solution to an ODE or ODE system. When initial<br />

conditions are given, such as in this problem, the series is calculated at the<br />

given point. Otherwise, the series is calculated at the origin. The ¯rst method<br />

used is a Newton iteration, the second involves a direct substitution to generate<br />

a system of equations which must be solved, while the third is the method of<br />

Frobenius discussed in standard ODE texts. Useful references may be found by<br />

entering the topic dsolve,series in Maple's Topic Search.<br />

> sol[n]:=dsolve(fde,icg,y(x),'series');<br />

To remove the \order of" term that appears in the output of the last command<br />

line, the convert( ,polynom) command is applied to the right-hand side of the<br />

nth order solution. The largest term in the series for Yn is x n¡1 .<br />

> Y[n]:=convert(rhs(sol[n]),polynom);<br />

The absolute percentage error at x = X is calculated for each order,<br />

> percent[n]:=abs(evalf(100*(Ynum(X)-eval(Y[n],x=X))/Ynum(X)));<br />

and the do loop ended with a colon to suppress the lengthy output.<br />

> end do:<br />

The loop stops at N = n ¡ 1, in this case order 17, for which the percentage<br />

error (to 3 digits) is 0.696 percent. As you can check by either replacing the<br />

colonwithasemicoloninthedolooportakingN = n¡ 2, the percentage error<br />

in order 16 is 1.31 percent. Order 17 is the ¯rst order for which the percentage<br />

error drops below one percent. The corresponding polynomial representation<br />

of the solution is given by Y17.<br />

> N:=n-1; evalf(percent[N],3)*percent; Y[N]:=Y[N];<br />

N := 17 0:696 percent<br />

Y17 := 1 + 1<br />

15 x3 + 1<br />

70 x4 + 4<br />

1575 x5 + 29<br />

20790 x6 + 43<br />

126126 x7 61<br />

+<br />

1001000 x8<br />

16013<br />

+<br />

1033782750 x9 498307<br />

+<br />

152770117500 x10 7710323<br />

+<br />

14115958857000 x11<br />

2117887<br />

+<br />

21250934424720 x12 96270661<br />

+<br />

5534097506437500 x13 121568353967<br />

+<br />

46021554863534250000 x14<br />

1141494706493<br />

+<br />

2859910909376771250000 x15 2799853112879<br />

+<br />

47283860368362618000000 x16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!