Mathematical Tools for Physics

(coco) #1
11—Numerical Analysis 331

wherejandkare the order ofh. Note that because this term appears in an expression multiplied byh^2 , it
doesn’t matter whatjis. You can choose it for convenience. Possible values for these are


(1)j= 0 k=hf(0,y 0 )
(2)j= 0 k=hf(h,y 0 )

(3)j=h k=hf(0,y 0 )
(4)j=h k=hf(h,y 0 ).

The third of these choices for example gives

y=y 0 +hf(0,y 0 ) +

h^2
2

[


1


h

[


f(h,y 0 )−f(0,y 0 )

]


+f(0,y 0 )

f(h,y 0 +k)−f(h,y 0 )
hf(0,y 0 )

]


=y 0 +

h
2

f(0,y 0 ) +

h
2

f

(


h,y 0 +hf(0,y 0 )

)


. (36)


This procedure, a second order Runge-Kutta method, is a moderately accurate method for advancing from one
point to the next in the solution of a differential equation. It requires evaluating the function twice for each step
of the iteration.
Example:y′= 1 +y^2 y(0) = 0. Let h=0.1


x y(Euler) y(RK2) tan x








        1. 0.1 0.10 0.10050 0.10053
          0.2 0.20100 0.20304 0.20271
          0.3 0.30504 0.30981 0.30934
          0.4 0.41435 0.42341 0.42279 (37)








The error atx= 0. 4 with RK2 is 0.15% and with Euler it is 2.0%. A commonly used version of this is the fourth
order Runge-Kutta method:


y=y 0 +

1


6


[


k 1 + 2k 2 + 2k 3 +k 4

]


(38)


k 1 =hf

(


0 ,y 0

)


k 3 =hf

(


h/ 2 ,y 0 +k 2 / 2

)


k 2 =hf

(


h/ 2 ,y 0 +k 1 / 2

)


k 4 =hf

(


h,y 0 +k 3

)


.

Free download pdf