Differential Equations - Runga Kutta Method

This is an applet to explore the numerical Runge Kutta method. This method which may be used to approximate solutions to differential equations is very powerful.

However the truncation error generated by this method has to be understood in order to make a good use of it.
Consider the following differential equation:

y' = f(x , y)

with y(x0) = K (initial or starting value of y)

We wish to approximate the solution to this equation over the interval [a,b]. Let divide this interval into n smaller intervals of size h. A numerical approximation to the above differential equation may be obtained using the 4th order Runge Kutta method as follows.
let y0 = K

yi+1 = yi + (1/6) [k1 + 2k2 + 2k3 + k4]

for i=0,1,...,n-1

where
y0 = K (starting value) k1 = hf(xi,yi) , k2 = hf(xi+h/2,yi+k1/2) , k3 = hf(xi+h/2,yi+k2/2) , k4 = hf(xi+h,yi+k3)
The local truncation error is of the order O(h5) and in principle decreases as h decreases.
The exploration is carried by changing the step size h.
Your browser is completely ignoring the <APPLET> tag!
TUTORIAL
All the differential equations used in the applet have the same initial value y(0) = 1 and exact solutions for comparison.
1 - click on the button above "click here to start" and MAXIMIZE the window obtained.
2 - Select the first (left panel, top) differential equation y' = x2. At the start h = 1.25 and n = 8. Examine the exact (ex value) solution and the approximate (ap value) one on the left panel. Decrease h by increasing n, read h and n top right. Any differences?
3 - Select the second diffenrial equation y' = x4. Explore by deceasing h and compare the exact and approximate values.

4 - Select the two other differential equations and analyze the results. Compare the exact and approximate values.

More references on differential equations.
Introduction to Differential Equations