Runge-Kutta (RK4) Method Calculator

Published on: December 7, 2025

This Runge-Kutta (RK4) Method Calculator helps you approximate the solution of a first-order differential equation and shows each step clearly. It works by combining four slope estimates at each step to produce a more accurate approximation than simpler numerical methods. This makes it useful for checking answers, understanding how the Runge-Kutta (RK4) method works, and practising differential equations step by step.

Step-by-step method

  1. Rewrite the ODE as y' = f(x,y).
  2. Read the IVP: y(x0) = y0, choose step size h and steps n.
  3. Compute k1 = f(xk, yk).
  4. Compute k2 = f(xk + h/2, yk + (h/2)k1).
  5. Compute k3 = f(xk + h/2, yk + (h/2)k2).
  6. Compute k4 = f(xk + h, yk + hk3).
  7. Update: y(k+1) = yk + (h/6)(k1 + 2k2 + 2k3 + k4).

Formula bank:

RK4: y' = f(x,y)
k1 = f(xk, yk)
k2 = f(xk+h/2, yk+(h/2)k1)
k3 = f(xk+h/2, yk+(h/2)k2)
k4 = f(xk+h, yk+hk3)
yk+1 = yk + (h/6)(k1+2k2+2k3+k4)

Example 1: dy/dx = x + y, x, y, y(0)=1, h=0.2, n=4

Step 1 - Write y' = f(x,y).

In this problem: Use the ODE in explicit slope form.

y′ = x + y

Step 2 - Read parameters.

In this problem: Use the initial condition and RK4 settings.

y(0) = 1
h = 0.2, n = 4

Step 3 - RK4 update (k=0).

In this problem: Compute k1, k2, k3, k4 and update y.

x0 = 0, y0 = 1
k1 = f(x0, y0) = 1
k2 = f(0.1, 1.1) = 1.2
k3 = f(0.1, 1.12) = 1.22
k4 = f(0.2, 1.244) = 1.444
y1 = 1.2428

Step 4 - RK4 update (k=1).

In this problem: Compute k1, k2, k3, k4 and update y.

x1 = 0.2, y1 = 1.2428
k1 = f(x1, y1) = 1.4428
k2 = f(0.3, 1.38708) = 1.68708
k3 = f(0.3, 1.411508) = 1.711508
k4 = f(0.4, 1.5851016) = 1.9851016
y2 = 1.58363592

Step 5 - RK4 update (k=2).

In this problem: Compute k1, k2, k3, k4 and update y.

x2 = 0.4, y2 = 1.58363592
k1 = f(x2, y2) = 1.98363592
k2 = f(0.5, 1.781999512) = 2.281999512
k3 = f(0.5, 1.8118358712) = 2.3118358712
k4 = f(0.6, 2.0460030942) = 2.6460030942
y3 = 2.0442129127

Step 6 - RK4 update (k=3).

In this problem: Compute k1, k2, k3, k4 and update y.

x3 = 0.6, y3 = 2.0442129127
k1 = f(x3, y3) = 2.6442129127
k2 = f(0.7, 2.308634204) = 3.008634204
k3 = f(0.7, 2.3450763331) = 3.0450763331
k4 = f(0.8, 2.6532281793) = 3.4532281793
y4 = 2.6510416516

Step 7 - Summary table.

In this problem: All RK4 iterations in one table.

kxkykk1k2k3k4yk+1
00111.21.221.4441.2428
10.21.24281.44281.687081.7115081.98510161.58363592
20.41.583635921.983635922.2819995122.31183587122.64600309422.0442129127
30.62.04421291272.64421291273.0086342043.04507633313.45322817932.6510416516

Step 8 - Final answer.

In this problem: RK4 approximation at x_n.

y(xn) yn = 2.6510416516(xn = 0.8)

Final answer: Approximation

Example 2: dy/dx = y - x^2 + 1, x, y, y(0)=0.5, h=0.2, n=5

Step 1 - Write y' = f(x,y).

In this problem: Use the ODE in explicit slope form.

y′ = 1 + y − x2

Step 2 - Read parameters.

In this problem: Use the initial condition and RK4 settings.

y(0) = 0.5
h = 0.2, n = 5

Step 3 - RK4 update (k=0).

In this problem: Compute k1, k2, k3, k4 and update y.

x0 = 0, y0 = 0.5
k1 = f(x0, y0) = 1.5
k2 = f(0.1, 0.65) = 1.64
k3 = f(0.1, 0.664) = 1.654
k4 = f(0.2, 0.8308) = 1.7908
y1 = 0.8292933333

Step 4 - RK4 update (k=1).

In this problem: Compute k1, k2, k3, k4 and update y.

x1 = 0.2, y1 = 0.8292933333
k1 = f(x1, y1) = 1.7892933333
k2 = f(0.3, 1.0082226667) = 1.9182226667
k3 = f(0.3, 1.0211156) = 1.9311156
k4 = f(0.4, 1.2155164533) = 2.0555164533
y2 = 1.2140762107

Step 5 - RK4 update (k=2).

In this problem: Compute k1, k2, k3, k4 and update y.

x2 = 0.4, y2 = 1.2140762107
k1 = f(x2, y2) = 2.0540762107
k2 = f(0.5, 1.4194838317) = 2.1694838317
k3 = f(0.5, 1.4310245938) = 2.1810245938
k4 = f(0.6, 1.6502811294) = 2.2902811294
y3 = 1.648922017

Step 6 - RK4 update (k=3).

In this problem: Compute k1, k2, k3, k4 and update y.

x3 = 0.6, y3 = 1.648922017
k1 = f(x3, y3) = 2.288922017
k2 = f(0.7, 1.8778142187) = 2.3878142187
k3 = f(0.7, 1.8877034389) = 2.3977034389
k4 = f(0.8, 2.1284627048) = 2.4884627048
y4 = 2.1272026849

Step 7 - RK4 update (k=4).

In this problem: Compute k1, k2, k3, k4 and update y.

x4 = 0.8, y4 = 2.1272026849
k1 = f(x4, y4) = 2.4872026849
k2 = f(0.9, 2.3759229534) = 2.5659229534
k3 = f(0.9, 2.3837949803) = 2.5737949803
k4 = f(1, 2.641961681) = 2.641961681
y5 = 2.6408226927

Step 8 - Summary table.

In this problem: All RK4 iterations in one table.

kxkykk1k2k3k4yk+1
000.51.51.641.6541.79080.8292933333
10.20.82929333331.78929333331.91822266671.93111562.05551645331.2140762107
20.41.21407621072.05407621072.16948383172.18102459382.29028112941.648922017
30.61.6489220172.2889220172.38781421872.39770343892.48846270482.1272026849
40.82.12720268492.48720268492.56592295342.57379498032.6419616812.6408226927

Step 9 - Final answer.

In this problem: RK4 approximation at x_n.

y(xn) yn = 2.6408226927(xn = 1)

Final answer: Approximation