Problem with Euler’s method
In the previous article we have discussed Euler’s method. What is the exact problem with that approach? The problem is that it assumes the slope of the function to be constant in a given interval [x,x+h]. Euler’s method calculates the slope at the beginning of the interval – so at x – and assumes to be the same in the whole interval. This is why Runge-Kutta method came to be.
So Runge-Kutta method is more accurate approach. We have the k parameters: we calculate the slope of the function not just at the beginning of the [x,x+h] interval.
So we have to calculate the k parameters according to the formulas above. We have four of them: this is why this method is usually called 4-th order Runge-Kutta method. If we just consider the first k parameters, it is the Euler’s method. k1 has something to do with the beginning of the interval. The k2 and k3 parameters have something to do with the middle of the interval. Thats why we increment x by h/2. The k4 is about the end of the interval as you can see: x+h.
Let’s solve a concrete differential equation with Runge-Kutta method. For example dy(x)/dx=xy. The solution of this equation is something like an exponential function. It grows more rapidly than the standard exp(x) function.
As you can see we have to define the k parameters. Thus we make sure we calculate the slope of the function not just at the beginning of the interval. We calculate it at the middle point and at the end of the interval.