Runge-Kutta Methods

The program we wrote in class can be modified to loop over different values of n and print the resulting error in a table. The output of the program looks like
10    1.025448593046163e-03
20    4.670956141906470e-05
40    2.528044066861176e-06
80    1.437479595469207e-07
160    8.504710330946297e-09
320    5.161617687085562e-10
640    3.177485878580466e-11
1280    1.970613776325347e-12
2560    1.228739332503892e-13
5120    7.575537419590717e-15
To check whether the method converges with order 4 plot x−4 and the data from the above table on the same log-log graph using the commands
gnuplot> set style data lines
gnuplot> set logscale y
gnuplot> set logscale x
gnuplot> plot "rk4err.out", x**-4
The resulting plot is

Since the slope of the line produced by the data is approximately −4, this verifies the RK4 method is performing as a 4th order method.


Last Updated: Fri Oct 24 12:11:24 PDT 2014