Runge-Kutta RK4 Solver – ODE Integration
RK4 integrates y′=f(x,y) with four slope samples: y′=y from y(0)=1 reaches y(0.1)=1.105170 — 7 correct digits in one step of h=0.1.
Figures are estimates from this calculator’s standard formula — adjust the inputs in the tool below for your exact number.
How the RK4 Solver Works
RK4 weighs four slope probes across each step — at the left edge, twice at the midpoint, and at the right edge — and combines them with weights 1:2:2:1. For the test equation y′ = y, y(0) = 1, h = 0.1: the four slopes evaluate to k₁ = 1, k₂ = 1.05, k₃ = 1.0525, k₄ = 1.10525, giving y(0.1) = 1 + (0.1/6)(1 + 2.1 + 2.105 + 1.10525) = 1.1051702. The exact solution e⁰·¹ = 1.1051709 differs only in the 7th digit — RK4’s local error is O(h⁵). Euler’s method on the same step returns 1.1, off by 0.005. The calculator prints every k, the weighted update, a step table, and the global error against known solutions (exponential growth, decay, logistics). Halving h divides global error by 16, the signature of a 4th-order method.
- 1
Enter f(x, y) and initial values
The ODE right-hand side plus x₀, y₀
- 2
Set step h and target
e.g. h = 0.1 out to x = 1
- 3
Compute the four slopes
k₁…k₄ are listed per step
- 4
Advance and report error
The weighted update and exact-solution comparison appear
Use Cases
Physics Simulation
Integrate pendulum and orbit equations without closed forms
Engineering Models
RC-circuit and mixing-tank transients to 6 digits
Coursework
Compare RK4 vs Euler on y′ = y at h = 0.1
Tips
- 1
Local error O(h⁵), global O(h⁴) — halve h, cut error 16×
- 2
Weights 1:2:2:1 on the four slope samples
- 3
One RK4 step often beats ten Euler steps
Common Mistakes
Evaluating all four slopes at the left endpoint instead of staggering them
Using weights 1:1:1:1 — that collapses to a crude average
Believing RK4 handles stiff equations well; implicit methods are needed there
Skipping the error check against a known solution during development
FAQs
How accurate is one RK4 step of h=0.1 on y′=y?
What are the k slopes for that step?
Why choose RK4 over Euler?
What happens when h halves?
Does RK4 work for systems?
Related tools
Pick another tool to continue your calculation.
Scientific Calculator – Free Online Math Calculator
Free online scientific calculator: sin(30°) = 0.5, log(100) = 2, √144 = 12. Trig, powers, roots and constants, right in your browser.
Scientific Notation Calculator – Convert & Compare
45,000,000 = 4.5 × 10⁷ and 0.00032 = 3.2 × 10⁻⁴. Convert, multiply and compare numbers as a × 10ⁿ with 1 ≤ |a| < 10, steps shown.
Arithmetic Sequence Calculator – nth Term & Sum
Calculate any term and sum of an arithmetic sequence.
Geometric Sequence Calculator – nth Term & Sum
Calculate any term and sum of a geometric sequence.
Collatz Conjecture Calculator – 3n+1 Steps
Trace the Collatz sequence for any number.
Lucas Sequence Calculator – Terms & Sums
Calculate Lucas sequence numbers.