ENSPERSE

Mathematical Modeling

Euler vs RK4 on the Lorenz system

How do endpoint error and runtime differ when both methods take the same steps?

Reproducible experiment

Setup

Start at (1, 1, 1) with Lorenz parameters σ = 10, ρ = 28 and β = 8/3. Both methods take 100 fixed steps of 0.008 to reach t = 0.8. Euler evaluates the derivative once per step; classical RK4 evaluates it four times.

The endpoint error is the Euclidean distance from a reference computed using RK4 with a step 16 times smaller. The reference is numerical, not an exact solution. The timing is the median of seven batches of 200 runs after warm-up and excludes rendering.

Results

Recorded results Node 22.15.0 (x64)
MethodRuntime per run (ms)Endpoint error
Euler0.0045406.29376
RK40.0302762.72967e-05

For this trajectory and step size, RK4 took longer and ended much closer to the reference than Euler. These timings describe one machine and runtime. The comparison fixes the number of steps, not the error target. It does not measure long-term predictability or establish which method is fastest at equal accuracy.

Reproduce the comparison

Download the three files below into the same directory and run the command with Node.js 22.15 or later. It prints the numerical errors and repeats the timing on your machine.

node benchmark.mjs

The interactive lab uses RK4 and lets you compare two nearby initial states. Its controls round β to 2.667; use the script for the exact benchmark setup.

Research archiveOpen the Lorenz lab