252 8 Differential equations
k 3 =h f(ti+h/ 2 ,yi+k 2 / 2 ). (8.11)
- With the latter slope we can in turn predict the value ofyi+ 1 via the computation of
k 4 =h f(ti+h,yi+k 3 ). (8.12)
- The final algorithm becomes then
yi+ 1 =yi+^1
6
(k 1 + 2 k 2 + 2 k 3 +k 4 ). (8.13)
Thus, the algorithm consists in first calculatingk 1 withti,y 1 andfas inputs. Thereafter, we
increase the step size byh/ 2 and calculatek 2 , thenk 3 and finallyk 4. With this caveat, we can
then obtain the new value for the variabley. It results in four function evaluations, but the
accuracy is increased by two orders compared with the second-order Runge-Kutta method.
The fourth order Runge-Kutta method has a global truncationerror which goes likeO(h^4 ).
Fig. 8.1 gives a geometrical interpretation of the fourth-order Runge-Kutta method.
✲
y
t
✻
ti
yiandk 1
yi+ 1 andk 4
yi+ 1 / 2 andk 2
yi+ 1 / 2 andk 3
ti+h/ 2 ti+h
Fig. 8.1Geometrical interpretation of the fourth-order Runge-Kutta method. The derivative is evaluated at
four points, once at the intial point, twice at the trial midpoint and once at the trial endpoint. These four
derivatives constitute one Runge-Kutta step resulting in the final value foryi+ 1 =yi+ 1 / 6 (k 1 + 2 k 2 + 2 k 3 +k 4 ).