Lably
Skip to content

Runge–Kutta methods

Family of implicit and explicit iterative methods

  • 11 min read
  • 9 chapters

Related on Lably

Through Numerical analysis, Differential equation and Big O notation

The fourth-order Runge–Kutta method

The most widely known member of the Runge–Kutta family is generally referred to as "RK4", the "classic Runge–Kutta method" or simply as "the Runge–Kutta method".

Let an initial value problem be specified as follows:

dydt=f(t,y),y(t0)=y0.

Here y is an unknown function (scalar or vector) of time t, which we would like to approximate; we are told that dydt, the rate at which y changes, is a function of t and of y itself. At the initial time t0 the corresponding y value is y0. The function f and the initial conditions t0, y0 are given.

Now we pick a step-size h > 0 and define:

yn+1=yn+h6(k1+2k2+2k3+k4),tn+1=tn+h

for n = 0, 1, 2, 3, ..., using

k1=f(tn,yn),k2=f(tn+h2,yn+k1h2),k3=f(tn+h2,yn+k2h2),k4=f(tn+h,yn+hk3).

(Note: the above equations have different but equivalent definitions in different texts.)

Here yn+1 is the RK4 approximation of y(tn+1), and the next value (yn+1) is determined by the present value (yn) plus the weighted average of four increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by function f on the right-hand side of the differential equation.

  • k1 is the slope at the beginning of the interval, using y (Euler's method);
  • k2 is the slope at the midpoint of the interval, using y and k1;
  • k3 is again the slope at the midpoint, but now using y and k2;
  • k4 is the slope at the end of the interval, using y and k3.

In averaging the four slopes, greater weight is given to the slopes at the midpoint. If f is independent of y, so that the differential equation is equivalent to a simple integral, then RK4 is Simpson's rule.

The RK4 method is a fourth-order method, meaning that the local truncation error is on the order of O(h5), while the total accumulated error is on the order of O(h4).

In many practical applications the function f is independent of t (so called autonomous system, or time-invariant system, especially in physics), and their increments are not computed at all and not passed to function f, with only the final formula for tn+1 used.

Sign in to keep reading

8 more chapters are free with a Lably account.

More in Calculus and analysis