Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Differential Equations formulas

Fourth-order Runge–Kutta

Advance an initial-value solution using four slope samples.

Differential Equations · Numerical methods
$$y_{n+1}=y_n+\frac h6(k_1+2k_2+2k_3+k_4)$$

Fourth-order Runge–Kutta is one of 2 numerical methods formulas in the differential equations section of this library, and it is used at university level.

Why fourth-order runge–kutta works

Instead of trusting one slope for the whole step, the method takes four readings: one at the start, two probing the midpoint, and one at the far end. Averaging them with the midpoint readings weighted double matches the Taylor expansion of the true solution through the h⁴ term, so the error per step is far smaller than the step size.

What each symbol means

$k_1=f(x_n,y_n)$, $k_2=f(x_n+h/2,y_n+hk_1/2)$, $k_3=f(x_n+h/2,y_n+hk_2/2)$, and $k_4=f(x_n+h,y_n+hk_3)$.

Fourth-order Runge–Kutta: when it holds

Use a sufficiently smooth differential equation and monitor numerical error as step size changes.

When it stops applying

The midpoint samples assume the slope function behaves smoothly across the step. A sudden switch in the forcing term partway through a step makes those samples describe two different problems, so the step boundaries should be lined up with the jump. Stiff equations still demand small steps despite the accuracy.

Fourth-order Runge–Kutta: a worked example

RK4 is generally much more accurate per step than Euler’s method for smooth problems.

The mistake to avoid

What people do: Students evaluate the middle slopes at the starting point, forgetting to advance both x and y before sampling.

Why it goes wrong: The two midpoint readings only add information because they are taken somewhere new. Sampling at the same place four times reduces the whole scheme to Euler's method with extra arithmetic.

Do this instead: Move both coordinates for each sample: k₂ uses x + h/2 together with y + hk₁/2, and k₃ uses x + h/2 with y + hk₂/2. Each k feeds the next, so they must be computed in order.

Fourth-order Runge–Kutta: step by step

  1. Name the unknown, and the unit the answer has to come out in.
  2. Match the symbols to your values. $k_1=f(x_n,y_n)$, $k_2=f(x_n+h/2,y_n+hk_1/2)$, $k_3=f(x_n+h/2,y_n+hk_2/2)$, and $k_4=f(x_n+h,y_n+hk_3)$.
  3. Check the conditions before substituting. Use a sufficiently smooth differential equation and monitor numerical error as step size changes.
  4. Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most differential equations slips.

Where this formula fits

Subject
Differential Equations formulas — 8 entries in this library
Topic
Numerical methods
Level
University

Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where fourth-order runge–kutta comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.

Questions about fourth-order runge–kutta

How much better is it than Euler's method?

Dramatically better. One step of size 0.1 on y' = y from y(0) = 1 gives 1.10517083 against the true 1.10517092, an error near 8 in the hundred-millionths, while Euler's 1.1 is off by about 0.0052.

Why are the two middle slopes weighted double?

Because the midpoint is the single best place to estimate the average slope across a step. The weights 1, 2, 2, 1 divided by 6 are what make the errors cancel through fourth order.

Does it cost four function evaluations per step?

Yes, so each step is four times the work of an Euler step. It still wins easily, since it reaches a given accuracy with vastly fewer steps than Euler needs.

Can I use it on a system of equations?

Yes, and the formula does not change. Treat y and each k as vectors and apply every line componentwise, which is also how a second-order equation gets solved after being split into two first-order ones.

Stuck on a problem?

Work a fourth-order runge–kutta problem step by step

Type your own problem, or upload a photo of it. You get the method, the answer, and a check you can repeat yourself.