Runge-Kutta (RK4) Method Calculator
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
- Rewrite the ODE as y' = f(x,y).
- Read the IVP: y(x0) = y0, choose step size h and steps n.
- Compute k1 = f(xk, yk).
- Compute k2 = f(xk + h/2, yk + (h/2)k1).
- Compute k3 = f(xk + h/2, yk + (h/2)k2).
- Compute k4 = f(xk + h, yk + hk3).
- Update: y(k+1) = yk + (h/6)(k1 + 2k2 + 2k3 + k4).
Formula bank:
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.
Step 2 - Read parameters.
In this problem: Use the initial condition and RK4 settings.
Step 3 - RK4 update (k=0).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 4 - RK4 update (k=1).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 5 - RK4 update (k=2).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 6 - RK4 update (k=3).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 7 - Summary table.
In this problem: All RK4 iterations in one table.
| k | xk | yk | k1 | k2 | k3 | k4 | yk+1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1.2 | 1.22 | 1.444 | 1.2428 |
| 1 | 0.2 | 1.2428 | 1.4428 | 1.68708 | 1.711508 | 1.9851016 | 1.58363592 |
| 2 | 0.4 | 1.58363592 | 1.98363592 | 2.281999512 | 2.3118358712 | 2.6460030942 | 2.0442129127 |
| 3 | 0.6 | 2.0442129127 | 2.6442129127 | 3.008634204 | 3.0450763331 | 3.4532281793 | 2.6510416516 |
Step 8 - Final answer.
In this problem: RK4 approximation at x_n.
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.
Step 2 - Read parameters.
In this problem: Use the initial condition and RK4 settings.
Step 3 - RK4 update (k=0).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 4 - RK4 update (k=1).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 5 - RK4 update (k=2).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 6 - RK4 update (k=3).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 7 - RK4 update (k=4).
In this problem: Compute k1, k2, k3, k4 and update y.
Step 8 - Summary table.
In this problem: All RK4 iterations in one table.
| k | xk | yk | k1 | k2 | k3 | k4 | yk+1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0.5 | 1.5 | 1.64 | 1.654 | 1.7908 | 0.8292933333 |
| 1 | 0.2 | 0.8292933333 | 1.7892933333 | 1.9182226667 | 1.9311156 | 2.0555164533 | 1.2140762107 |
| 2 | 0.4 | 1.2140762107 | 2.0540762107 | 2.1694838317 | 2.1810245938 | 2.2902811294 | 1.648922017 |
| 3 | 0.6 | 1.648922017 | 2.288922017 | 2.3878142187 | 2.3977034389 | 2.4884627048 | 2.1272026849 |
| 4 | 0.8 | 2.1272026849 | 2.4872026849 | 2.5659229534 | 2.5737949803 | 2.641961681 | 2.6408226927 |
Step 9 - Final answer.
In this problem: RK4 approximation at x_n.
Final answer: Approximation
Sign up or login to get the full step solution for free!