You are on page 1of 46

# NUMERICAL METHODS

5. NUMERICAL METHODS
5.0 INTRODUCTION

One of the most important tasks in a study of dynamical systems is the numerical calculation of the trajectories. Thus far we have considered the integration method to be a black box into which we pop the system, initial conditions, method and time range and out pops a plot of the trajectories. Although this approach is common in courses on dynamical systems it obscures many of the pitfalls of numerical integration. It is not possible at the present state of the art to choose a best! algorithm for the calculation of trajectories. There are several types of numerical algorithm, each with their own advantages and disadvantages. "e shall consider a class of methods known as discrete variable methods. These methods approximate the continuous time dynamical system by a discrete time system. This means that we are not really simulating the continuous system but a discrete system which may have different dynamical properties. This is an extremely important point. The discrete variable methods which we consider fall into two main types, RungeKutta methods and Linear Multistep methods. #aple has implementations of both types of method as well as a number of more sophisticated techni\$ues designed to overcome some of the pitfalls of numerical solution. The more sophisticated methods still fall into the discrete variable category.

5.1

TYPES O METHOD

Although the dynamical systems which we are simulating are usually in more than one dimension we can, without loss, restrict our numercal anlaysis of the methods to the single non&autonomous differential e\$uation = f t, x x

bg

subject to the initial condition x t ' = x' . "e shall usually refer to the differential e\$uation together with the initial condition as an initial value problem (I)*+. ,iscrete variable methods yield a series of approximations X n x (tn + on the set of points t n +- = t n + h , where h is the stepsi.e. Ta!lor Ser"es Metho# These methods are based on the Taylor series expansion h% h0 x (t n + + x (t n + + %/ 0/ n = ',- N

bg

(t n + + x (t n +- + = x ( t n + + hx

If the series is truncated and x (t n + is replaced by the approximation X n we obtain the Taylor Series Method of order p h % h 0 h p ( p+ X n +- = X n + hX n + Xn + X n ++ Xn %/ 0/ p/

where X ( p +

dpX . dt p

Although there is an implementation of this method in #aple it is not much used in practice due to the necessity of computing the higher order derivatives of X. "e shall only use it as a reference method when discussing the accuracy of other methods. R\$%&e'(\$tta Metho#s These methods are based on the notion of finding a formula which agrees with the Taylor series as closely as possible without involving derivatives. 1or example consider the possibility of matching the second order Taylor series method
%

## n +h X n X n +- = X n + hX %/ by using a formula of the form X n +- = X n + h ( t n , X n , h+ where

(t , x , h+ = f (t , x + + f (t + ah, x + bhf (t , x ++
The e\$uivalent Taylor series expression to (t , x , h+ is

(t + + ( t , x , h+ = x

h (t + x % h f t (t , x + + f x (t , x + f (t , x + % hg b gives

= f (t , x + +

## 2xpanding (t , x , h+ in a Taylor series up to terms of

(t , x , h+ = ( + + f (t , x + + h af t (t , x + + bf x (t , x + f (t , x + + (h % +
3

## 4omparing the two expressions we see that

+ = -,
resulting in the family of solutions

a = % ,

b =

= - ,

= ,

a=b=

## we obtain the improved !uler method

X n +- = X n +

h f (t n , X n + + f t n + h, X n + hf (t n , X n + %

## and for = - the modified !uler method

h X n +- = X n + hf t n + h % , X n + % f (t n , X n +

5nfortunately the terminology for naming second order 6unge&7utta methods is not standardised and #aple calls the improved 2uler method the 8eun formula and the modified 2uler method the improved polygon method. The procedure above can be extended to give higher order methods such as the classical "th order method h X n +- = X n + ( #- + % # % + % # 0 + # 3 + 9 #- = f ( t n , X n +
#% = f (t n + % h, X n + % h#- + #0 = f (tn + % h, X n + % h# % +

# 3 = f (t n + h, X n + h# 0 +

L"%ear M\$lt"ste) Metho#s These methods are based on integration of an interpolating polynomial having the values f n f (t n , X n + on a set of points t n at which X n has already been computed. ;y integrating = f t, x x

bg

## over the interval t n , t n +- we obtain

x t n +- x t n =

b g bg z f (t , x+dt
t n+tn

## 5sing linear interpolation in the interval we have t t b g bg zL M t t N

t n+tn n

x t n +- x t n

n +n +-

fn +

t tn f n +- dt t n +- t n

O P Q

Integrating gives f +f g b g bg h b %
n n +-

x t n +- x t n

X n +- = X n +

## The general form of these methods is

# #

% X n + % = h % f n + % ,
% =' % ='

n = ',-,%,

where % and % are constants, # ' . This formula is called a linear #-step method. In order to generate the se\$uence of approximations X n it is first necessary to obtain # starting values X ' , X - , , X # - . If # = ' the method is explicit. If # ' then the method is implicit and leads to a non&linear e\$uation for X n + # . The main methods of this type which we shall consider are< &dams-'ashforth These methods are explicit with methods of order # being #&step. #ethods of order from one to three have the formulae X n +- = X n + hf t n , X n X n +- = X n X n +- = X n
n

l q

b g h + m 0f b t ,X g fb t ,X g r % h + m %0 f b t ,X g -9 f b t ,X g +:f b t ,X g r -%
n n n n n n n n % n %

The first order method is more normally called the !uler method. &dams-Moulton These methods are implicit with methods of order # being # - &step. #ethods of order from one to three have the formulae X n +- = X n + hf t n +- , X n +X n +- = X n X n +- = X n
n +-

b g

b g h + m fb t ,X g + fb t ,X g r % h + m :f b t ,X g +=f b t ,X g fb t ,X g r -%
n +n n n +n +n n n n -

The first order method is called the backward 2uler formula and the second order method is the Trape.oidal method.

>

(ear Methods These methods are implicit with methods of order # being #&step. #ethods of order from one to three have the formulae X n +- = X n + hf t n +- , X n +X n +- = X n +- =
0 n n -

--

%h + fb t ,X g l3 X X q 0 9h + fb t ,X g l-= X ? X + % X q -n +n +n n n% n +n +-

## The first order method is again the backward 2uler formula.

5.*

MAPLE IMPLEMENTATION

#aple contains a large range of numerical procedures for integrating non& autonomous dynamical systems of the type = , t,+ , + t =+ b g +bg
'

'

All of these procedures are invoked using the #aple dsolve command with the numeric option. The syntax for the command is dsolve(de\$ns, vars, type@numeric, options+ where de\$ns defines the system of differential e\$uations and initial values, vars defines the dependent and independent variables, type@numeric tells #aple to use a numerical algorithm and options allows a choice of method, stepsi.e and other options associated with the method. The default method is a 1ehlberg fourth&fifth order 6unge&7utta method.

## -or.e# E+a/)le 1 ' 0a% #er Pol E1\$at"o%

As an example consider the solution of the )an der *ol e\$uation written as the first order system =y x

= x + - x% + y y

c h

A epsilon<@-'< A ivp <@ Bdiff(x(t+,t+@y(t+,diff(y(t+,t+@&x(t+CepsilonD(-&x(t+E%+Dy(t+, x('+@',y('+@'.:F< A fcns <@ Bx(t+, y(t+F< This defines the initial value problem. Gow we invoke dsolve A p-<@ dsolve(ivp,fcns,type@numeric+H p) <@ )roc (r#f"*+x+ ... e%#

Gote that the output from the dsolve command is a procedure. In order to find the numerical solution we need to evaluate the procedure at the appropriate value of t. A p-(-'+H I t =-', x( t + =&-.>39=9%3990':3==, y( t + =.'=3>9''>'%:=--3>3 J

"e can us the #aple odeplot command to graph the solution. This command is in the plots package so this has to be loaded first. A with(plots+<

Gow we can plot the solution in various ways. 1irstly here is a plot of the solution components v t over the range I',%'J. numpoints controls the number of plotted points which needs to be relatively high here to obtain a realistic plot. A odeplot(p-,IIt,x(t+J,It,y(t+JJ,'..%', numpoints@:''+H

## and a three dimensional plot A odeplot(p-,IIt,x(t+,y(t+JJ,'..%', numpoints@:''+H

-'

Class"cal Metho#s #aple contains a number of one&step methods for the numerical solution of initial value problems. These are referred to as classical methods and are invoked by including the option method@classicalItypeJ in the call to dsolve. 8ere type can be one of foreuler heunform impoly rk% rk0 rk3 adambash abmoulton the forward 2uler methodH the 8eun formula (also known as the trape.oidal rule, or the improved 2uler method+H the improved polygon method (also known as the modified 2uler method+H the second&order classical 6unge&7utta methodH the third&order classical 6unge&7utta methodH the fourth&order classical 6unge&7utta methodH the Adams&;ashford method (a KpredictorK method+H the Adams&;ashford&#oulton method (a Kpredictor& correctorK method+. If no type is specified the forward 2uler method is used.

--

## 4onsider the I)* y = % xy % , y ' =-

b g

"e can define this in #aple as A ivp<@Bdiff(y(x+,x+@&%DxDy(x+E%,y('+@-F< In this case #aple can find the exact solution using dsolve A 2xactsoln<@rhs(dsolve(ivp,y(x+++H x % +-

!xactsoln <@

Gow we use 2ulerLs method to obtain the numerical solution. Gote that this method like all the other methods of type classical uses a fixed stepsi.e which we provide. A es'<@dsolve(ivp,y(x+,type@numeric, method@classicalIforeulerJ,stepsi.e@'.''-+< Thus we can find the solution at x = '.3 A es'('.3+H I x =.3, y( x + =.=9%0'=:'?>3-3'99 J

## and plot the solution for a range of values of x A odeplot(es',Ix,y(x+J,'..9,labels@Ix,yJ+H

-%

Gow often we want to investigate how the solution behaves for differing values of the stepsi.e h. In order to do this we can define a different version of the function for the numerical solution which uses the stepsi.e as one of the input parameters A es-<@h&Adsolve(ivp,y(x+,type@numeric, method@classicalIforeulerJ,stepsi.e@h+< Thus we can obtain the solution for different stepsi.es A es-('.''-+('.3+H I x =.3, y( x + =.=9%0'=:'?>3-3'99 J A es-('.'-+('.3+H I x =.3, y( x + =.=933=3?%3==?'3?% J

"e can compare the solution at different stepsi.es by constructing a table of values as follows< 1irstly define the output points A x<@k&AkD'.-<

-0

Gow define a function which finds the approximate solution at a given output point A 2ulerMoln<@(x,h+&Arhs(es-(h+(x+I%J+< ,efine the exact solution A 2xactMoln<@x&A-N(-CxE%+H - +x %

!xactSoln <@ x

4onstruct an array whose elements compare the exact solution to the numerical solution for three different stepsi.es. A mm<@array(-..=,-..:+< mmI-,-J<@Ox(k+O<mmI-,%J<@O2xactsolnO<mmI-,0J<@Oh@'.-O< mmI-,3J<@Oh@'.'-O<mmI-,:J<@Oh@'.''-O< for i from % to = do mmIi,-J<@'.-D(i&%+< mmIi,%J<@evalf(2xactMoln(x(i&%++,:+< for j from 0 to : do mmIi,jJ<@evalf(2ulerMoln(x(i&%+,-'E(&jC%++,:+ od< od< A eval(mm+H x,#- !xact soln ' -. ..??'-' .% .?9-:3 .0 .?->30 .3 .=9%'> .: .='''' .9 .>0:%? h./0) h./0/) -. -. -. .??-'> .?=''' .?900' .?3-:= .?-?9? .===0? .=933= .=%:%: .='%%? .>:>-: .>0>%>
-3

## h./0//) -. .??'%' .?9->- .?->99 .=9%0- .=''%0 .>0:3?

Another possibility is to compare the errors at each stepsi.e. 1irstly define a function giving the error A err<@(x,h+&A2xactMoln(x+&2ulerMoln(x,h+< A tt<@array(-..=,-..3+< ttI-,-J<@Ox(k+O<ttI-,%J<@Oh@'.-O<ttI-,0J<@Oh@'.'-O<ttI-,3J<@Oh@'.''-O< for i from % to = do ttIi,-J<@'.-D(i&%+H for j from % to 3 do ttIi,jJ<@evalf(err(x(i&%+,-'E(&jC-++,:+H od< od< A eval(tt+H x,# ' . .% .0 .3 .: .9 h./0) ' &.''??' &.'-=39 &.'%3-: &.'%90% &.'%:%: &.'%-=9 h./0/) ' &.'''?> &.''->9 &.''%%9 &.''%3&.''%%? &.''-?= h./0//) ' &.'''-' &.'''-> &.'''%0 &.'''%3 &.'''%0 &.'''%'

## 4onsider the solution of the I)* y = 3 y + 3 x , y ' =-

b g

A I)*<@Bdiff(y(x+,x+@&3Dy(x+C3Dx,y('+@-F<

-:

## The exact solution is given by A dsolve(I)*,y(x++H - : ( 3 x + y( x + =x + e 3 3

5se the %nd order classical 6unge&7utta method A rk%<@h&Adsolve(I)*,y(x+,type@numeric,method@classicalIrk%J,stepsi.e@h+< A x<@k&AkD'.:< A 67%Moln<@(x,h+&Arhs(rk%(h+(x+I%J+< A 2xactMoln<@x&Ax&-N3C:N3Dexp(&3Dx+H - : ( 3 x + !xactSoln <@ x x + e 3 3

A mm<@array(-..-',-..:+< mmI-,-J<@Ox(k+O<mmI-,%J<@O2xactsolnO<mmI-,0J<@Oh@'.%:O< mmI-,3J<@Oh@'.:O<mmI-,:J<@Oh@'.>:O< for i from % to -' do mmIi,-J<@'.:D(i&%+< mmIi,%J<@evalf(2xactMoln(x(i&%++,:+< for j from 0 to : do mmIi,jJ<@evalf(67%Moln(x(i&%+,'.%:D(j&%++,:+ odH od< A eval(nm+H

-9

x,#- !xact soln ' -. .: .3-?-= -.' .>>%?' -.: -.%:0 %.' -.>:'3 %.: %.%:' 0.' %.>:'' 0.: 0.%:'' 3.' 0.>:''

## h./02* -. -.:''' %.0-%: ?.'9%: ?.:9%: -%.'-9 :-.:>= :%.'>= 93.>=:

Gote that as the stepsi.e is increased the numerical solution fails to represent the exact solution accurately. Indeed for a stepsi.e of '.>: the numerical solution Lblows upL. This is due to non&convergence as a result of the numerical method becoming unstable. "e shall consider this phenomenon next.

->

E+erc"ses 1 -. 5se the classical numerical methods foreuler, heunform, rk0, rk3 and adambash to attempt to obtain a numerical solution of the I)*s dx = %tx % , x ' = dt dx = :x - x , x ' = '.: dt

(a+

b g

(b+

b gb g

5se a range of stepsi.es in the interval I',-J. At what approximate value of the stepsi.e do the methods become unstable. %. 5se each of the methods above to solve the systems of differential e\$uations = x + xy , x = y xy , y = y, x = x + (- x + y , y
%

(a+

(b+

## where is a parameter. (Try = '.:,-,:,-' +. = ( y + \$ +, x = x + '.% y , y = '.% =\$ + x\$ , \$ x ('+ = y ('+ = \$ ('+ = -

(c+

In each case use odeplot to obtain time series and phase plots.

-=

5.3

## LOCAL AND 4LO5AL ERRORS

The output of a discrete variable method is a set of points t n , X n and the output of the dynamical system is a continuous trajectory x t . 1or the numerical results to provide a good approximation to the trajectory we re\$uire that the difference X N x tN < where is some defined error tolerance, at each solution point. This difference is called the global error and is the accumulated error over all solution steps. 5nfortunately it is extremely difficult to accomplish this and we have to confine ourselves to controlling the local error P X n x tn

b g

bg

bg

P at each step where X n is the numerical solution obtained on the assumption that the numerical solution at the previous solution point is exact. There are two sources of local error,the roundoff error and the truncation error. Ro\$%#o,, Error The roundoff error is the error which arises from the fact that numerical methods are implemented on digital computers which only calculate results to a fixed precision which is dependent on the computer system used. Gote that since roundoff errors depend only on the number and type of arithmetic operations per step and is thus independent of the integration stepsi.e h. Tr\$%cat"o% Error The truncation error of a numerical method results from the approximation of a continuous dynamical system by a discrete one. The truncation error is machine independent, depending only on the algorithm used and the stepsi.e h.

-?

An important concept in the analysis of the truncation error is that of consistency. ;asically consistency re\$uires that the discrete variable method becomes an exact representation of the dynamical system as the stepsi.e h ' . 4onsistency conditions can be derived for both Qinear #ultistep and 6unge&7utta methods. Linear Multistep Methods 4onsider the general linear multistep method
# #

% X n + % = h % f n + % ,
% =' % ='

n = ',-,%,

#

( + = i i
i ='

#

( + = i i
i ='

## "e can show that consistency re\$uires that

(-+ = ',

(-+ = (-+

Runge-Kutta Methods The general pth order 6unge&7utta method can be written in the form

%'

3n +- = 3n + h c r # r #- = f t n , X n #r
n

b g F = fG t + ha , X H
r

r =-

n + h brs # s , s =-

I J K

r = %,0, p

8ere we have

## = and it can be shown that consistency re\$uires that

m

bg

(-+ = ',

c
r =-

= (-+

-or.e# E+a/)le 6

2xamine the consistency of (a+ the classical 3th order 6unge&7utta method, (b+ the two&step Adams&;ashforth method.
3

(a+

( + = ( + = -

c
r =-

- - - + + + =9 0 0 9

thus
3

(-+ = '

(-+ = - = cr
r =-

## and hence the method is consistent.

%-

(b+

( + = % ( + = % -

0 ( + = % %

thus

(-+ = '
and hence the method is consistent.

(-+ = - = (-+

The accuracy with which a consistent numerical method represents a dynamical system is determined by the order of consistency. The method of determining this is best illustrated by an example. -or.e# E+a/)le 5

,etermine the order of consistency of the Trape.oidal method. The order of consistency is determined by substituting the exact solution xn into the formula of the numerical algorithm and expanding the difference between the two sides of the formual by Taylor series. The result is then normalised by multiplying by the scaling factor . - h

b g

( + = ( + = thus

( + = + % %

(-+ = '

(-+ = - = (-+

## and the method is consistent. Gow the truncation error is given by

%%

L O b g M P b gN Q -L h O +x g = M x x b x P hN % Q R U h h + x + hx x + x + | | % 9 -| | = S V I hF h h| +x + hx + x G x x +J| | | % % H K T W
= h xn +- xn f n + f n + - h %
n +n n n +0 % n n n n % n n n n n

h% xn + -%

The order is given by the highest power of h remaining. 8ence the method is consistent of order two.

%0

5.6

7ERO STA5ILITY

This is a problem peculiar to consistent linear #&step methods in which a first order dynamical system is integrated using a #th order difference e\$uation. This leads to the possible existence of spurious solutions of the difference e\$uation which can swamp the desired solution. In order to avoid this occuring we have to restrict the roots of the first characteristic polynomial to satisfy the root condition.

bg

De,"%"t"o% R Root 4ondition "e say that a linear #&step method satisfies the root condition if the roots of the characteristic polynomial ( + all lie within or on the unit circle, those on the unit circle being simple. Gote that the roots of ( + may be complex hence the necessity of considering the , in the definition. unit circle rather than the interval --

Theore/ 8 5ero-Stability A a linear #&step method is .ero stable if and only if it satisfies the root condition. "e can now state the fundamental theorem concerning convergence<

Theore/ ' 4onvergence A discrete variable method is convergent if and only if it is both consistent and .ero stable. Often it is desirable for the roots of ( + to satisfy the strong root condition.

%3

De,"%"t"o% R Strong Root 4ondition A linear #&step method is said to satisfy the strong root condition if the characteristic polynomial has a simple root at - = - and all the remaining roots lie strictly within the unit circle. The roots i , - i # of ( + for a consistent method satisfying the root condition can be categori.ed as

- = i , i -, % i # i , i = -, % i m i , i < -, m + - i #

-or.e# E+a/)le 9

## Mhow that the Sear method

X n +- =

l3 X

X n - +

t ,X g q %0h f b
n +n +-

is convegent. ;efore determining the characteristic polynomials write in the standard form %h f t # +% , X # +% 0

X # +% 3 0 X # +- + 0 X # =

Then
=% 3 0 + 0,

bg

% =% 0

bg

%:

4hecking consistency
- = - 3 0 + 0 = ',

b g

% - = % 3 0 = 0 = -

b g

b g

## The roots of are given by

bg

bg = b 0 -g -g b
0

=% 3 0 + 0 = '

= -, 0 and hence the method is .ero&stable. 4ombining these results we can conclude that the method is convergent.

%9

## E+erc"ses * -. (a+ Mhow that the method

h [ f n+% + (- ) f n +- f n ] %

X n +% (- + ) X n +- + X n =

is consistent and determine the value of the method. (b+ %. 1ind the range of values of Mhow that Tuade!s method

## for which the method is .ero stable.

X n +3

= ( X n +0 X n +- ) X n = 9h ( f n +3 + 3 f n +0 + 3 f n +- + f n ) -? -?

is both consistent and .ero stable. 0. Mhow that the 0&step Sear method
(-= X n+% ? X n +- + % X n ) = 9h f n+0 ---

X n +0

## is both consistent and .ero stable.

%>

5.6

A5SOLUTE STA5ILITY

Mo far we have considered the behaviour of numerical methods in the limit as the stepsi.e h ' . 8owever in practice we must deal with finite stepsi.es. To illustrate the problems that might arise consider the mid&point method X n +- = X n - + %hf n This is a linear two&step method. In standard form the method is X n + % X n = %hf n +thus

= % -, = %
4hecking consistency

bg

bg

- = -% - = ',

b g

- = % - = -

b g

b g

The roots of are given by = - hence the method is both consistent and .ero& stable and hence convergent. Gow consider the solution of the initial value problem = %tx % , x x ' =-

bg

b g

by the mid&point method using a stepsi.e h = '. . 5sing #aple we define the initial value problem A f<@(t,x+&A&%DtDx(t+E%<x'<@-< A I)*<@Bdiff(x(t+,t+@f(t,x+,x('+@x'F< A 14G<@Bx(t+F<
%=

## "e can find the exact solution A 2xact<@rhs(dsolve(I)*,14G++H

The mid&point method re\$uires a starting value which can be obtained from the classical fourth order 6unge&7utta method A sv<@h&Adsolve(I)*,14G,type@numeric,method@classicalIrk3J,stepsi.e@h+< A M)<@(t,h+&Arhs(sv(h+(t+I%J+< Gow define the mid&point method A midpt<@proc(n,h+ option rememberH if n@- then M)(h,h+ elif n@% then x'C%DhDf(h,M)(h,h++ else midpt(n&%,h+C%DhDf((n&-+Dh,midpt(n&-,h++fiH end< Obtain a plot of the solution A plotmidpt<@proc(G,h+ local l,iH l<@IJH for i from - to G do l<@Iop(l+,iDh,midpt(i,h+JH odH pointplot(l,connect@true+H end< 1inally plot both the numerical and exact solutions

%?

## A with(plots+< A p-<@plotmidpt(:','.-+< A p%<@plot(2xact,t@'..:+< A display(Bp-,p%F+H

Gotice that the numerical solution becomes increasingly innacurate, oscillating about the exact solution, as t increases. This behaviour arises because the behaviour of the numerical solution does not mimic that of the exact solution. In this case the problem arises because of a spurious solution of the difference e\$uation corresponding to the root = - of . 8owever the problem can also arise in one&step methods which have no spurious solutions. 4onsider the Qinear #ultistep method.
# #

bg

i3n+i = h i f n+i
i =' i ='

0'

3
i ='

i n +i

= h i 3n +i
i ='

Thus
# #

## i3n+i h i3n+i = '

i =' i ='

Qet 3n = n , then
# #

i i h i i = '
i =' i ='

8ence

( H h + ( + h ( + = ' ( H h + is called the stability polynomial of the method. Gow one of the roots - (h + will correspond to the true solution, the other roots will lead to spurious
solutions whose magnitude will have to be controlled to obtain stability. De,"%"t"o% R &bsolute Stability A numerical method is said to be absolutely stable for a given h if all the roots of

## ( H h + lie within the unit circle.

A region R & of the complex plane is said to be a region of absolute stability if the method is stable for all h in R & .

0-

-or.e# E+a/)le :

1ind and sketch the region of absolute stability for (a+ 2ulerLs method, (b+ Trape.oidal method. (a+ 1or 2ulerLs method

( H h + = (- + h +
Thus - + h < -

6A -% '

( H h + = -

Thus

0%

6A '

## 1or 6unge&7utta methods the stability polynomial has the form

( H h + = - + ' h ' h

bg

where ' is a polynomial for an explicit method and a rational function for an implicit method.

00

-or.e# E+a/)le ;

1ind and sketch the absolute stability region for the second order 6unge&7utta method h #- + # % %

3n +- = 3n +

b g

where #- = f xn , 3n #%
n

b g = fb x + h, 3 + h# g
n -

## Mubstituting into the test e\$uation #- = f xn , 3n = h3n #% Thus 3n +- = 3n + h3n + h % % 3n % h % % = - + h + 3n %

n n

b g = fb x + h, 3 + h# g = h3 + h 3
% % n

F G H

I J K

## 8ence the stability polynomial is given by

( H h + = - + h +

F G H

h % % %

I J K

## 1or absolute stability we re\$uire that h % % <%

- + h +

03

In order to draw the region of absolute stability consider the boundary R & of R & . The locus of this boundary will be the set of complex numbers \$ such that

-+ \$ +

\$% =%

Thus \$% - + \$ + = ei , %

' < %

In order to obtain the region we need to plot the roots of the \$uadratic e\$uation \$ % + % \$ + % %ei = ' for in the range ' < % . This is best done on a computer. The resulting stability region is shown below<

The method outlined above is an example of the boundary locus method which is easily implemented for Qinear #ultistep methods as follows. The stability polynomial is

0:

( H h + ( + h ( + = '
and hence

h =

( + ( +

but on R &

= -, thus

= ei ,

' < %

8ence the locus of the boundary R & is given by the set of complex numbers \$ satisfying

\$=

ch , c e h
ei
i

' < %

X n +- =

l3 X

X n - +

t ,X g q %0h f b
n +n +-

=% 3 0 + 0,

bg

% =% 0

bg

## Thus the stability polynomial is given by

% % ( H h + % 3 0 + 0 0 h = '

09

\$=

\$=

## which gives the plot

In order to determine whether R & is the interior or exterior of the closed curve choose a point inside the curve, say \$ = - and evaluate the roots of ( H h + .
% % % 3 0 + 0 0 = '

% 3 + - = ' 3 3% 3 = =% 0 % and we see that on of the roots, % + 0 , has modulus greater than one and hence R & must consist of the exterior of the closed curve.

0>

-or.e# E+a/)le 10

Mhow that the mid&point method X n +- = X n - + %hf t n , X n has an empty region of absolute stability. 1rom above

b g

= % -, = %
Thus the stability polynomial is given by

bg

bg

( H h + % - %h = '
Mubstituting \$ = h and solving

\$=

% %

## Gow substitute = ei to obtain e %i - ei e i = = i sin %ei %

\$=

which does not bound any region of the complex plane. 8ence R & is empty.

0=

E+erc"ses 3 -. Mhow, using the boundary locus method, that Tuade!s method
= ( X n +0 X n +- ) X n = 9h ( f n +3 + 3 f n +0 + 3 f n +- + f n ) -? -?

X n +3

has no real region of absolute stability. %. ,etermine the regions of absolute stability of the methods
h ( %0 f n +% -9 f n +- + : f n ) -%

## (a+ (b+ (c+ (d+

X n +0 = X n +% + X n +% = X n +- + X n +0 = X n +3 =

h ( : f n+% + = f n +- f n ) -%

0?

APPENDIX 1

## ANSWERS AND HINTS OR THE E=ERCISES

3'

Metho#s E+erc"ses 1 -. 5se the method outlined in section to obtain tables comparing the exact and numerical solutions for a variety of stepsi.es. %. 5se the method outlined in section to obtain solutions and plots with the odeplot command. Co%s"ste%c! a%# 7ero Sta>"l"t! E+erc"ses *
0 % 3 0 bg bg - xn h + %3 0 xn h + -. (a+ Truncation error is -% order when = - . (b+ #ethod is .ero stable if - < - . 3 = = 0 + -? -, = %. = -? 9' -?

b g bg

b g

h h c hence maximum
3

bg b -g = ', b -g = bg bg

## = - and roots of are -, -,

b g

9 -?

%3 0 %3 9 3 + -? + -? + -? , hence

bg

3 -?

03: -?

## absolute value one.

0 % 0 9 ? % 9 - = ', - = -= - and 0. = -= -- + -- -- , = -- , hence

bg

b g b g

b g

> %%

0? %%

3-

3%

APPENDIX 2

## MAPLE WORK SHEETS

30

-or.e# E+a/)le 5 ' Deter/"%"%& The Or#er o, a N\$/er"cal Metho# A restart< ,efine a function to represent the exact solution A x<@t&Ax(t+< 5se some aliases for the derivatives of x A alias(x-@,(x+,x%@(,UU%+(x+,x0@(,UU0+(x+,x3@(,UU3+(x+, x:@(,UU:+(x+,x9@(,UU9+(x+,x>@(,UU>+(x+,x=@(,UU=+(x++< 5se the taylor command to obtain a Taylor series expansion of x(tnCh+ A ts<@taylor(x(t+,t@tn,?+< 6eplace t&tn by h in the expansion A tsh<@subs(t&tn@h,ts+< 4onvert to a polynomial so that we can perform the algebra later A p<@unapply(convert(tsh,polynom+,h+< 6epeat above for xL(tnCh+ A dts<@taylor(x-(t+,t@tn,=+< A dtsh<@subs(t&tn@h,dts+< A dp<@unapply(convert(dtsh,polynom+,h+< 2ulerLs #ethod A simplify(p(h+&x(tn+&hDx-(tn++H Trape.oidal 6ule A simplify(p(h+&x(tn+&hD(x-(tn+Cdp(h++N%+H TuadeLs #ethod A simplify(p(3Dh+&=D(p(0Dh+&p(h++N-?&x(tn+&9DhD(dp(3Dh+C3Ddp(0Dh+C3Ddp(h+ Cx-(tn++N-?+H

33

-or.e# E+a/)le < A restart< A with(plots+< ,efine the characteristic polynomials A rho<@theta&AthetaE%&3DthetaN0C-N0H A sigma<@theta&A%N0DthetaE%H and the stability polynomial A pi<@theta&Arho(theta+&lambdaDhDsigma(theta+H Mubstitute . @ hDlambdaH A pi.<@theta&Arho(theta+&.Dsigma(theta+H ,efine the boundary of the region A rat<@solve(pi.(theta+,.+H A rat-<@subs(theta@exp(IDphi+,rat+H *lot the boundary A complexplot(rat-,phi@'..%D*i,numpoints@:''+H 4heck whether region is inside or outside closed curve A rs<@solve(subs(.@-,pi.(theta++@',theta+H #ust be outside.

3:

-or.e# E+a/)le 10 A restart< A with(plots+< ,efine the characteristic polynomials A rho<@theta&AthetaE%&-H A sigma<@theta&A%DthetaH 1ind the stability polynomial A pi<@theta&Arho(theta+&lambdaDhDsigma(theta+H A pi.<@theta&Arho(theta+&.Dsigma(theta+H Molve for . A rat<@solve(pi.(theta+,.+H Mubstitute theta @ eE(iDphi+H A rat-<@subs(theta@exp(IDphi+,rat+H Mimplify the result A simplify(rat-+H Thus empty region of absolute stability.

39