Mathematics / Runge-Kutta Fourth-Order (RK4)
FREE TO EXPLORE
LABORATORY 32 · MATHEMATICS

Classical Fourth-Order Runge-Kutta (RK4) Integration & Convergence

Implement the classical four-stage Runge-Kutta (RK4) algorithm for nonlinear dynamical systems, analyze the Butcher tableau, evaluate the four intermediate slope evaluations k₁, k₂, k₃, k₄, and verify the fourth-order O(h⁴) global truncation error convergence. Explore interactive numerical methods, evaluate error attenuation and verify convergence orders.

COMPUTE · CONVERGE · ANALYSE

Your virtual mathematics laboratory.

RK4 GLOBAL ERROR ||Y - Y_NUM||_∞—
COMPUTATION STATUS

Ready to execute Step = 1.

1 step
Classical Butcher tableau: c = [0, 1/2, 1/2, 1]ᵀ, b = [1/6, 1/3, 1/3, 1/6] (matching Simpson quadrature weights)

Adjust Step, then execute computation.

Mathematical operations are computed deterministically using 64-bit IEEE 754 precision. Residuals reflect ordinary least-squares regression across successive observations.

Numerical assumptions and limits

RK4 is an explicit algorithm: on stiff problems with rapid decay modes, it requires impractically small time steps to maintain stability. The simulation executes classical RK4 for time steps h = 0.20 / 2^{k-1} on the nonlinear test IVP y' = y cos(t). The maximum trajectory error is measured against the exact analytic solution exp(sin(t)). The logarithmic regression ln(E) = α·ln(h) + ln(C) extracts the asymptotic order α = 4.000 with R² = 1.000000.

Computational tools & numerical modules.

Butcher Stage Evaluator

Evaluates intermediate vector fields k₁ = f(t, y), k₂ = f(t + h/2, y + h k₁/2), k₃ = f(t + h/2, y + h k₂/2), k₄ = f(t + h, y + h k₃).

Weighted Stage Combiner

Assembles the weighted Simpson-like increment y_{n+1} = y_n + (h/6) [k₁ + 2 k₂ + 2 k₃ + k₄].

Analytic Benchmark Comparator

Computes exact reference solution y(t) = exp(sin(t)) to determine instantaneous and maximum global error.

Order Barrier Analyzer

Demonstrates why achieving order p = 5 requires 6 stages, making 4-stage RK4 the sweet spot of computational efficiency.

Complex Stability Boundary Mapper

Plots the stability boundary |1 + z + z²/2 + z³/6 + z⁴/24| = 1 in the complex z = λh plane.

Log-Log Regression Slope Processor

Computes ordinary least-squares slope on (ln(h), ln(E_max)) to verify fourth-order convergence α = 4.000.

FOLLOW THE METHOD

A reason behind every step.

Implement the classical four-stage Runge-Kutta (RK4) algorithm for nonlinear dynamical systems, analyze the Butcher tableau, evaluate the four intermediate slope evaluations k₁, k₂, k₃, k₄, and verify the fourth-order O(h⁴) global truncation error convergence. Standardized input settings: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 step.

01

Initialize IVP Manifold & Analytic Benchmark

Set up dy/dt = y cos(t) with y(0) = 1.0 on t ∈ [0, π], verifying the exact solution y(t) = exp(sin(t)).

02

Set Step Size Refinement Schedule

Assign step sizes h = 0.20 / 2^{k-1} across refinement levels k = 1 to 6 (h ∈ [0.20, 0.10, 0.05, 0.025, 0.0125, 0.00625]).

03

Execute Four-Stage Intermediate Slopes

At each time step, compute initial slope k₁, two midpoint trial slopes k₂ and k₃, and endpoint trial slope k₄.

04

Perform Weighted Simpson Increment

Advance state vector via y_{n+1} = y_n + (h/6) [k₁ + 2k₂ + 2k₃ + k₄] and update time t_{n+1} = t_n + h.

05

Measure Supremum Global Discrepancy

Sample trajectory across all time nodes and record maximum absolute error E_max = ||y(t_n) - y_n||_∞.

06

Verify Fourth-Order Asymptotic Slope

Plot ln(E_max) versus ln(h) and compute the linear regression gradient to confirm α = 4.000 with R² = 1.000000.

YOUR NOTEBOOK · 0 OBSERVATIONS

Turn measurements into mathematical insight.

See a complete example report ↗

Points are your recorded observations. The solid regression line validates Runge-Kutta Fourth-Order (RK4) mathematical scaling.

LINEAR ASYMPTOTIC FIT · y = mx + b
ln(E_max) = α · ln(h) + ln(C)
#Time Step Setting (k) (step)RK4 Global Error ||y - y_num||_∞ (error)Logarithmic Time Step ln(h)Logarithmic Global Error ln(E_max)Remove

No readings yet. Execute a computation and record it.

Calculate it yourself.

CHECK YOUR UNDERSTANDING

Explain what the mathematical metrics mean.

What is the global truncation error order of convergence α of the classical four-stage Runge-Kutta (RK4) algorithm?

According to the Butcher order barriers, what is the minimum number of stages required to construct an explicit Runge-Kutta method of order p = 5?

When applied to an autonomous linear test equation y' = λy, what is the stability polynomial R(z) for RK4?

Why does RK4 evaluate intermediate slopes k₂ and k₃ at the midpoint time t + h/2?