---
name: rk4
description: "Accurate fixed-step solution of a smooth, non-stiff ordinary differential equation y' = f(t, y) over short to medium times. Classical fourth-order Runge-Kutta method with four evaluations of f per step; no error control. Not structure-preserving: energy drifts in long conservative simulations, and it is unstable for stiff problems."
---

# Classical Runge-Kutta (RK4)

> **Placeholder (demo).** Description only: there is no reference implementation or verification for this entry yet. It belongs to a demonstration set of textbook methods.

## What it does

Combines four slope evaluations per step, at the start, twice at the midpoint and at the end, with weights 1/6, 1/3, 1/3, 1/6. The global error is fourth order: halving the step reduces it about sixteenfold.

## When to use

- Smooth, non-stiff problems where a fixed step is acceptable and you want high accuracy per unit of work, for example a short integration whose step size you already know is adequate.

## When not to use (and what to use instead)

| Situation | Use instead |
| --- | --- |
| You do not know a good step size, or need a guaranteed tolerance | `dormand-prince-rk45` (adaptive, with error estimate) |
| Long runs of a conservative mechanical system: energy drifts slowly | `stormer-verlet` or `yoshida4` |
| Stiff problem | `backward-euler` or `implicit-midpoint` |
| Output needed at arbitrary times between steps | `dormand-prince-rk45` (dense output) |

## Key facts

Order 4, explicit, not symplectic, not time-reversible, conditionally stable, four evaluations per step.

## Sources

- E. Hairer, S. P. Nørsett, G. Wanner. *Solving Ordinary Differential Equations I*, 2nd rev. ed. Springer, 1993. https://doi.org/10.1007/978-3-540-78862-1
