FAILURE MAP
← Case archive

FA-87001 / Physics integrator stability / Open access

RK4 second stage samples the forcing at the start of the step · case 01

Driven oscillators lag the drive phase and resonance peaks shift.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Stage two evaluates f at t instead of t+dt/2.

THE FAILURE

Stage two evaluates f at t instead of t+dt/2.

Unsuccessful approach: Using t+dt for stage two samples the end of the interval.

Case contract

solve(x0, v0, k, c, F, wf, dt, steps): unit mass x''=-k*x-c*v+F*cos(wf*t) with wf in rad/s, t starting at 0, integrated with classical RK4. Return [x, v, t] rounded to 6.

Why this case matters

Game and robotics physics loops depend on integrator update order, step control and stabilization terms; a wrong decision point turns a stable simulation into drifting or exploding motion.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x0, v0, k, c, F, wf, dt, steps):
    def f(t, x, v):
        return v, -k * x - c * v + F * math.cos(wf * t)
    t = 0.0
    x, v = x0, v0
    for _ in range(steps):
        k1x, k1v = f(t, x, v)
        k2x, k2v = f(t, x + dt / 2 * k1x, v + dt / 2 * k1v)
        k3x, k3v = f(t + dt / 2, x + dt / 2 * k2x, v + dt / 2 * k2v)
        k4x, k4v = f(t + dt, x + dt * k3x, v + dt * k3v)
        x = x + dt / 6 * (k1x + 2 * k2x + 2 * k3x + k4x)
        v = v + dt / 6 * (k1v + 2 * k2v + 2 * k3v + k4v)
        t = t + dt
    return [round(x, 6), round(v, 6), round(t, 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[-0.109, -0.682, 16.643, 0.151, 1.208, 3.199, 0.05, 3], [-0.171504, -0.13078, 0.15]], [[-0.61, 0.229, 19.238, 1.044, 0.247, 2.469, 0.2, 5], [0.139704, -1.592733, 1.0]], [[0.554, 0.274, 1.952, 1.469, 0.422, 2.192, 0.05, 5], [0.591752, 0.03687, 0.25]], [[0.282, 0.543, 8.523, 0.076, 0.449, 0.819, 0.05, 3], [0.33886, 0.203549, 0.15]], [[0.477, 0.804, 9.463, 0.795, 0.343, 4.866, 0.2, 1], [0.539279, -0.178827, 0.2]], [[-0.227, 0.276, 16.723, 1.386, 1.542, 0.923, 0.05, 4], [-0.091739, 0.96699, 0.2]], [[0.594, 0.724, 5.574, 1.414, 0.54, 2.544, 0.2, 5], [0.050911, -1.000788, 1.0]], [[0.689, 0.052, 16.201, 1.057, 1.522, 3.299, 0.1, 4], [0.142181, -2.089598, 0.4]]], [[[-0.015, -0.728, 3.619, 0.305, 1.759, 0.971, 0.05, 5], [-0.129743, -0.181737, 0.25]], [[0.202, -0.76, 9.287, 0.346, 0.41, 1.102, 0.1, 8], [-0.203071, 0.226236, 0.8]], [[-0.383, 0.162, 14.847, 0.091, 1.671, 1.112, 0.1, 3], [-0.052582, 1.777728, 0.3]], [[-0.254, 0.589, 19.18, 1.426, 1.766, 0.574, 0.2, 2], [0.188947, 1.001027, 0.4]], [[0.35, 0.024, 2.459, 0.489, 1.678, 3.184, 0.2, 2], [0.401172, 0.137673, 0.4]], [[-0.926, 0.952, 5.429, 0.55, 1.365, 4.948, 0.2, 1], [-0.633361, 1.884933, 0.2]], [[-0.492, -0.144, 14.57, 1.424, 1.521, 1.605, 0.05, 3], [-0.421761, 1.012157, 0.15]], [[-0.032, 0.808, 18.227, 0.749, 0.437, 3.703, 0.1, 1], [0.04836, 0.775101, 0.1]]], [[[0.389, 0.616, 7.403, 1.127, 1.629, 2.121, 0.2, 1], [0.470821, 0.193297, 0.2]], [[0.041, 0.318, 13.053, 1.284, 1.13, 3.854, 0.1, 10], [-0.108393, -0.480589, 1.0]], [[0.156, -0.808, 12.089, 0.635, 0.926, 3.013, 0.05, 7], [-0.092465, -0.474045, 0.35]], [[-0.571, 0.019, 10.668, 1.333, 0.813, 4.88, 0.1, 10], [0.238859, -0.217571, 1.0]], [[0.14, -0.995, 4.311, 1.362, 1.859, 1.467, 0.1, 1], [0.053608, -0.732895, 0.1]], [[0.97, 0.167, 11.672, 1.058, 1.37, 3.646, 0.05, 1], [0.965896, -0.326628, 0.05]], [[-0.187, -0.668, 4.72, 0.983, 1.179, 4.274, 0.1, 9], [-0.169823, 0.117475, 0.9]], [[-0.394, 0.849, 18.783, 1.27, 1.837, 1.788, 0.1, 10], [0.047492, -1.406422, 1.0]]], [[[-0.078, 0.138, 15.586, 0.722, 1.531, 2.959, 0.2, 11], [0.289495, 0.434261, 2.2]], [[-0.484, -0.908, 18.372, 0.481, 1.964, 2.315, 0.2, 2], [-0.051507, 2.343495, 0.4]], [[-0.155, 0.536, 12.075, 0.427, 1.31, 1.501, 0.05, 5], [0.046382, 0.960851, 0.25]], [[-0.198, -0.028, 4.048, 0.079, 1.642, 1.588, 0.2, 8], [0.361524, -1.100738, 1.6]], [[-0.772, 0.752, 2.823, 0.497, 1.621, 2.92, 0.1, 6], [0.065151, 1.550767, 0.6]], [[0.978, -0.619, 6.532, 0.841, 1.56, 4.863, 0.1, 5], [0.259021, -2.015912, 0.5]], [[-0.384, 0.592, 12.646, 0.775, 0.505, 4.99, 0.1, 4], [0.075224, 1.216664, 0.4]], [[0.222, 0.427, 18.578, 0.025, 1.284, 1.076, 0.05, 10], [0.064518, -0.805375, 0.5]]], [[[0.96, 0.368, 6.136, 0.868, 0.713, 4.277, 0.1, 13], [-0.632372, -0.226167, 1.3]], [[-0.527, 0.382, 9.694, 0.75, 1.418, 3.954, 0.05, 3], [-0.405723, 1.184269, 0.15]], [[0.855, -0.044, 17.022, 0.515, 0.279, 4.577, 0.05, 7], [0.150264, -3.175431, 0.35]], [[0.48, 0.991, 13.504, 0.938, 1.754, 1.99, 0.2, 8], [-0.112907, 0.598276, 1.6]], [[-0.477, 0.275, 5.669, 0.697, 1.555, 1.138, 0.1, 5], [0.032203, 1.424819, 0.5]], [[0.613, 0.575, 19.459, 1.488, 0.738, 4.191, 0.1, 1], [0.612276, -0.562497, 0.1]], [[-0.789, -0.272, 3.161, 0.072, 0.574, 2.141, 0.2, 5], [0.127601, 1.403065, 1.0]], [[-0.341, 0.921, 14.484, 0.78, 0.993, 4.954, 0.1, 11], [-0.092121, -0.961694, 1.1]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("case %d" % i, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
case 0[-0.171458, -0.129866, 0.15][-0.171504, -0.13078, 0.15]Failed
case 1[0.141157, -1.593265, 1.0][0.139704, -1.592733, 1.0]Failed
case 2[0.591786, 0.03728, 0.25][0.591752, 0.03687, 0.25]Failed
case 3[0.338861, 0.203572, 0.15][0.33886, 0.203549, 0.15]Failed
case 4[0.539523, -0.176619, 0.2][0.539279, -0.178827, 0.2]Failed
case 5[-0.091728, 0.967156, 0.2][-0.091739, 0.96699, 0.2]Failed
case 6[0.05745, -0.990845, 1.0][0.050911, -1.000788, 1.0]Failed
case 7[0.143993, -2.077818, 0.4][0.142181, -2.089598, 0.4]Failed

SHA-256 / 648a3a03faecbae89cb118e82d4ef17e93210e487a477a778c7226d89f6264c0

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x0, v0, k, c, F, wf, dt, steps):
    def f(t, x, v):
        return v, -k * x - c * v + F * math.cos(wf * t)
    t = 0.0
    x, v = x0, v0
    for _ in range(steps):
        k1x, k1v = f(t, x, v)
        k2x, k2v = f(t + dt, x + dt / 2 * k1x, v + dt / 2 * k1v)
        k3x, k3v = f(t + dt / 2, x + dt / 2 * k2x, v + dt / 2 * k2v)
        k4x, k4v = f(t + dt, x + dt * k3x, v + dt * k3v)
        x = x + dt / 6 * (k1x + 2 * k2x + 2 * k3x + k4x)
        v = v + dt / 6 * (k1v + 2 * k2v + 2 * k3v + k4v)
        t = t + dt
    return [round(x, 6), round(v, 6), round(t, 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[-0.109, -0.682, 16.643, 0.151, 1.208, 3.199, 0.05, 3], [-0.171504, -0.13078, 0.15]], [[-0.61, 0.229, 19.238, 1.044, 0.247, 2.469, 0.2, 5], [0.139704, -1.592733, 1.0]], [[0.554, 0.274, 1.952, 1.469, 0.422, 2.192, 0.05, 5], [0.591752, 0.03687, 0.25]], [[0.282, 0.543, 8.523, 0.076, 0.449, 0.819, 0.05, 3], [0.33886, 0.203549, 0.15]], [[0.477, 0.804, 9.463, 0.795, 0.343, 4.866, 0.2, 1], [0.539279, -0.178827, 0.2]], [[-0.227, 0.276, 16.723, 1.386, 1.542, 0.923, 0.05, 4], [-0.091739, 0.96699, 0.2]], [[0.594, 0.724, 5.574, 1.414, 0.54, 2.544, 0.2, 5], [0.050911, -1.000788, 1.0]], [[0.689, 0.052, 16.201, 1.057, 1.522, 3.299, 0.1, 4], [0.142181, -2.089598, 0.4]]], [[[-0.015, -0.728, 3.619, 0.305, 1.759, 0.971, 0.05, 5], [-0.129743, -0.181737, 0.25]], [[0.202, -0.76, 9.287, 0.346, 0.41, 1.102, 0.1, 8], [-0.203071, 0.226236, 0.8]], [[-0.383, 0.162, 14.847, 0.091, 1.671, 1.112, 0.1, 3], [-0.052582, 1.777728, 0.3]], [[-0.254, 0.589, 19.18, 1.426, 1.766, 0.574, 0.2, 2], [0.188947, 1.001027, 0.4]], [[0.35, 0.024, 2.459, 0.489, 1.678, 3.184, 0.2, 2], [0.401172, 0.137673, 0.4]], [[-0.926, 0.952, 5.429, 0.55, 1.365, 4.948, 0.2, 1], [-0.633361, 1.884933, 0.2]], [[-0.492, -0.144, 14.57, 1.424, 1.521, 1.605, 0.05, 3], [-0.421761, 1.012157, 0.15]], [[-0.032, 0.808, 18.227, 0.749, 0.437, 3.703, 0.1, 1], [0.04836, 0.775101, 0.1]]], [[[0.389, 0.616, 7.403, 1.127, 1.629, 2.121, 0.2, 1], [0.470821, 0.193297, 0.2]], [[0.041, 0.318, 13.053, 1.284, 1.13, 3.854, 0.1, 10], [-0.108393, -0.480589, 1.0]], [[0.156, -0.808, 12.089, 0.635, 0.926, 3.013, 0.05, 7], [-0.092465, -0.474045, 0.35]], [[-0.571, 0.019, 10.668, 1.333, 0.813, 4.88, 0.1, 10], [0.238859, -0.217571, 1.0]], [[0.14, -0.995, 4.311, 1.362, 1.859, 1.467, 0.1, 1], [0.053608, -0.732895, 0.1]], [[0.97, 0.167, 11.672, 1.058, 1.37, 3.646, 0.05, 1], [0.965896, -0.326628, 0.05]], [[-0.187, -0.668, 4.72, 0.983, 1.179, 4.274, 0.1, 9], [-0.169823, 0.117475, 0.9]], [[-0.394, 0.849, 18.783, 1.27, 1.837, 1.788, 0.1, 10], [0.047492, -1.406422, 1.0]]], [[[-0.078, 0.138, 15.586, 0.722, 1.531, 2.959, 0.2, 11], [0.289495, 0.434261, 2.2]], [[-0.484, -0.908, 18.372, 0.481, 1.964, 2.315, 0.2, 2], [-0.051507, 2.343495, 0.4]], [[-0.155, 0.536, 12.075, 0.427, 1.31, 1.501, 0.05, 5], [0.046382, 0.960851, 0.25]], [[-0.198, -0.028, 4.048, 0.079, 1.642, 1.588, 0.2, 8], [0.361524, -1.100738, 1.6]], [[-0.772, 0.752, 2.823, 0.497, 1.621, 2.92, 0.1, 6], [0.065151, 1.550767, 0.6]], [[0.978, -0.619, 6.532, 0.841, 1.56, 4.863, 0.1, 5], [0.259021, -2.015912, 0.5]], [[-0.384, 0.592, 12.646, 0.775, 0.505, 4.99, 0.1, 4], [0.075224, 1.216664, 0.4]], [[0.222, 0.427, 18.578, 0.025, 1.284, 1.076, 0.05, 10], [0.064518, -0.805375, 0.5]]], [[[0.96, 0.368, 6.136, 0.868, 0.713, 4.277, 0.1, 13], [-0.632372, -0.226167, 1.3]], [[-0.527, 0.382, 9.694, 0.75, 1.418, 3.954, 0.05, 3], [-0.405723, 1.184269, 0.15]], [[0.855, -0.044, 17.022, 0.515, 0.279, 4.577, 0.05, 7], [0.150264, -3.175431, 0.35]], [[0.48, 0.991, 13.504, 0.938, 1.754, 1.99, 0.2, 8], [-0.112907, 0.598276, 1.6]], [[-0.477, 0.275, 5.669, 0.697, 1.555, 1.138, 0.1, 5], [0.032203, 1.424819, 0.5]], [[0.613, 0.575, 19.459, 1.488, 0.738, 4.191, 0.1, 1], [0.612276, -0.562497, 0.1]], [[-0.789, -0.272, 3.161, 0.072, 0.574, 2.141, 0.2, 5], [0.127601, 1.403065, 1.0]], [[-0.341, 0.921, 14.484, 0.78, 0.993, 4.954, 0.1, 11], [-0.092121, -0.961694, 1.1]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("case %d" % i, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
case 0[-0.171576, -0.132036, 0.15][-0.171504, -0.13078, 0.15]Failed
case 1[0.138371, -1.590801, 1.0][0.139704, -1.592733, 1.0]Failed
case 2[0.591707, 0.036378, 0.25][0.591752, 0.03687, 0.25]Failed
case 3[0.338858, 0.203517, 0.15][0.33886, 0.203549, 0.15]Failed
case 4[0.538603, -0.184941, 0.2][0.539279, -0.178827, 0.2]Failed
case 5[-0.091755, 0.966782, 0.2][-0.091739, 0.96699, 0.2]Failed
case 6[0.04352, -1.008191, 1.0][0.050911, -1.000788, 1.0]Failed
case 7[0.139731, -2.103016, 0.4][0.142181, -2.089598, 0.4]Failed

SHA-256 / 974bc519a09bb51e99d39ec4637865ebb34d4692f5b30ffc36928e6d380a9e20

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic bounded teaching model with stipulated toy conventions and rounded float output; not a production physics engine or a proof of numerical stability. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:54.708765+00:00.

Case digest / 9d736106f706d3325fc9c45db9f346fb099e0ae7915f5a89f9bb79f64029668e