fhat. GitHub Workspace

Classical Runge-Kutta (RK4)

Accurate short-to-medium runs for smooth, non-stiff ODEs.

errorO(h4)cost4 f / stepexplicit

Placeholderv0.1.3Example

Use with your agent

Use the fhat method "rk4" (https://fhat.dev/methods/rk4/SKILL.md) for this problem. Check first whether it applies.

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

The methods shown are examples. More research methods are coming.