Runge-Kutta RK4 Calculator
March a first-order ODE with classical fourth-order Runge-Kutta, printing the first ten steps and the final value.
Runge-Kutta RK4 Calculator
March a first-order ODE with classical fourth-order Runge-Kutta, printing the first ten steps and the final value.
How this page computes
The page takes four slope samples per step with the classical RK4 weights and prints the first ten rows plus the final value. The method order and step count are stated.
The calculation runs entirely in this browser tab; nothing is uploaded.
The page solves dy/dx = f(x, y) with classical fourth-order Runge-Kutta and prints the first ten steps and the final value. Worked example: y' = x + y from y(0) = 1 with h = 0.1 reaches about 3.4366 at x = 1.
Four slope samples are combined per step, so the method is fourth-order and much more accurate than Euler at the same h. The page names the method and the step count instead of claiming an exact solution.
How to use the Runge-Kutta RK4 Calculator
Enter the slope in x and y, set the initial values, the step size and the number of steps, then press Run. The table shows the first ten rows and the final line gives the endpoint value.
Each row is one RK4 step, not one slope sample: the four internal samples are combined before the row is printed. That keeps the table readable while the method still does its four evaluations.
The classical RK4 weights
At each step the page evaluates the slope at the start, at two midpoint estimates and at an endpoint estimate, then combines them with weights 1, 2, 2, 1 over 6. That is the classical fourth-order Runge-Kutta rule.
The local error is O(h^5) and the global error O(h^4), which is why the same step count is far more accurate than Euler. The page prints the step count so the approximation is read with its order.
What to Expect
Best for
- A more accurate numerical ODE solution
- Comparing RK4 with Euler at the same h
- Checking a hand-computed RK4 step
Not ideal for
- A stiff equation needing an implicit method
- A symbolic closed form
- Adaptive step control
What this tool keeps
- The slope, initial values, step size and step count
What may need cleanup
- The final value is an approximation; RK4 is fourth-order at this step count
Common errors
- A non-finite slope is refused at its x and y
- A zero step size is refused
Example use cases
- Solve y' = x + y from (0, 1)
- Compare RK4 and Euler at ten steps
Sample input
x + y
Sample output
RK4 for dy/dx = x + y, y(0) = 1, h = 0.1, 10 steps n = 0: x = 0, y = 1 n = 1: x = 0.1, y = 1.11034166667 n = 2: x = 0.2, y = 1.2428051417 n = 3: x = 0.3, y = 1.39971699413 n = 4: x = 0.4, y = 1.58364848016 n = 5: x = 0.5, y = 1.79744127719 n = 6: x = 0.6, y = 2.04423592418 n = 7: x = 0.7, y = 2.32750325319 n = 8: x = 0.8, y = 2.65107912658 n = 9: x = 0.9, y = 3.01920282756 final: y(1) ≈ 3.43655948827 classical fourth-order Runge-Kutta; the stated step count is the whole approximation
Who this is for
- Students learning RK4
- Readers checking a numerical solution
Frequently asked questions
Why is RK4 more accurate than Euler?
RK4 combines four slope estimates per step with weights that cancel lower-order error terms, leaving a fourth-order global error. Euler uses one slope per step and is first-order, so RK4 is far closer at the same h.
Does the table show the internal samples?
No. Each printed row is one completed step; the four internal evaluations are part of that step. Showing them as rows would misstate the step count and make the table four times longer.
What equations are supported?
First-order equations written as dy/dx = f(x, y), with x and y available in the expression. The page evaluates the slope numerically at each sample, so non-linear equations are fine as long as the slope stays finite.
Is anything uploaded?
Nothing is uploaded. The four slope samples and the recurrence run in this browser tab, and reloading the page discards the expression and the table.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.