python-rk45-dormand-prince-adaptive-events
Done. The verified solution is complete and self-contained.
~| File | Purpose |
|---|---|
SOLUTION.md |
The required deliverable: title, root-cause analysis, exact fix (full source, ~450-line pure-NumPy module), and verification section with captured output |
rk45_dp.py |
The working module (embedded in the markdown, byte-identical) |
verify_rk45.py |
The verification harness (also embedded) |
A from-scratch adaptive Dormand–Prince RK5(4) integrator (no SciPy — only NumPy) with:
err = h·(B5−B4)·K, scaled-RMS norm, accept/reject loop with FSAL (7th stage reused as the next derivative)h_{n+1} = h_n·safety·err_n^{−kP/5}·err_{n−1}^{−kI/5} (kP=0.7, kI=0.4); integral action drives steady-state error to a fixed value and kills step-size oscillationg(H(τ)) to locate zero crossings, plus a re-integration/rebisect refinement loop that stops exactly on terminal events (bracket shrinks as width⁴ per cycle → machine precision)y'=y: global relative error tracks rtol (2.1e-9 @ rtol=1e-9)max|ΔE| = 1.9e-9, max|ΔL| = 6.9e-10 (< 1e-8); 50 orbits → 5.3e-10t[-1] == t_events[0][0] exactlyA round-trip test confirmed the markdown-embedded sources are byte-identical to the files and run correctly, so the document is directly usable as-is.
# Evidence - Problem class: python-rk45-dormand-prince-adaptive-events - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-29T22:38:53.652Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement an adaptive-step Dormand-Prince RK45 integrator with embedded error estimation and PI step-size control, plus dense-output event detection that locates zero crossings (bisection on the cubic Hermite interpolant) and stops integration exactly at the event. Validate it on the Kepler two-body problem (energy/angular-momentum drift below 1e-8 over many orbits), the van der Pol oscillator in a stiff regime, and exact event-time recovery for bouncing-ball and pendulum root-finding cases.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "python-rk45-dormand-prince-adaptive-events", "provider": "openrouter", "solved_at": "2026-08-29T22:38:53.652Z", "version": "3.11"}Done. The verified solution is complete and self-contained.
~| File | Purpose |
|---|---|
SOLUTION.md |
The required deliverable: title, root-cause analysis, exact fix (full source, ~450-line pure-NumPy module), and verification section with captured output |
rk45_dp.py |
The working module (embedded in the markdown, byte-identical) |
verify_rk45.py |
The verification harness (also embedded) |
A from-scratch adaptive Dormand–Prince RK5(4) integrator (no SciPy — only NumPy) with:
err = h·(B5−B4)·K, scaled-RMS norm, accept/reject loop with FSAL (7th stage reused as the next derivative)h_{n+1} = h_n·safety·err_n^{−kP/5}·err_{n−1}^{−kI/5} (kP=0.7, kI=0.4); integral action drives steady-state error to a fixed value and kills step-size oscillationg(H(τ)) to locate zero crossings, plus a re-integration/rebisect refinement loop that stops exactly on terminal events (bracket shrinks as width⁴ per cycle → machine precision)y'=y: global relative error tracks rtol (2.1e-9 @ rtol=1e-9)max|ΔE| = 1.9e-9, max|ΔL| = 6.9e-10 (< 1e-8); 50 orbits → 5.3e-10t[-1] == t_events[0][0] exactlyA round-trip test confirmed the markdown-embedded sources are byte-identical to the files and run correctly, so the document is directly usable as-is.
# Evidence - Problem class: python-rk45-dormand-prince-adaptive-events - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-29T22:38:53.652Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement an adaptive-step Dormand-Prince RK45 integrator with embedded error estimation and PI step-size control, plus dense-output event detection that locates zero crossings (bisection on the cubic Hermite interpolant) and stops integration exactly at the event. Validate it on the Kepler two-body problem (energy/angular-momentum drift below 1e-8 over many orbits), the van der Pol oscillator in a stiff regime, and exact event-time recovery for bouncing-ball and pendulum root-finding cases.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "python-rk45-dormand-prince-adaptive-events", "provider": "openrouter", "solved_at": "2026-08-29T22:38:53.652Z", "version": "3.11"}