FAILURE MAP
← Case archive

FA-17076 / Floating-point arithmetic / Open access

Closeness sums tolerances instead of choosing the larger · case 01

Closeness sums tolerances instead of choosing the larger.

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

ROOT CAUSE

Closeness sums tolerances instead of choosing the larger. The faulty expression is return difference<=abs_tol+relative.

THE FAILURE

Closeness sums tolerances instead of choosing the larger. The faulty expression is return difference<=abs_tol+relative.

Unsuccessful approach: The attempted local correction return difference<=2*max(abs_tol,relative) still violates the explicit regression fixtures.

Case contract

Symmetric binary64 closeness: equal values including like-signed infinities are close; remaining nonfinite pairs are not. For finite a,b require abs(a-b)<=max(abs_tol,rel_tol*max(abs(a),abs(b))). Negative tolerances return invalid.

Why this case matters

An offline floating representation model isolates a reproducible arithmetic fault.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(a,b,rel_tol,abs_tol):
    if rel_tol<0 or abs_tol<0: return 'invalid'
    if a==b: return True
    if not math.isfinite(a) or not math.isfinite(b): return False
    difference=abs(a-b)
    relative=rel_tol*max(abs(a),abs(b))
    return difference<=abs_tol+relative
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal infinity', solve(math.inf,math.inf,1e-9,0.0), True)
check('opposite infinity', solve(math.inf,-math.inf,1e-9,0.0), False)
check('nan', solve(math.nan,math.nan,1.0,1.0), False)
check('absolute zero', solve(0.0,N*1e-9,0.0,N*1e-9), True)
check('relative boundary', solve(float(N),float(N*2),0.5,0.0), True)
check('reverse relative', solve(float(N*2),float(N),0.5,0.0), True)
check('negative values', solve(-float(N),-float(N*2),0.5,0.0), True)
check('disjoint tolerances', solve(0.0,1.5,0.5,1.0), False)
check('ordinary apart', solve(float(N),float(N+1),1e-6,0.0), False)
check('bad relative', solve(1.0,1.0,-1.0,0.0), "invalid")
check('bad absolute', solve(1.0,1.0,0.0,-1.0), "invalid")
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
equal infinityTrueTruePassed
opposite infinityFalseFalsePassed
nanFalseFalsePassed
absolute zeroTrueTruePassed
relative boundaryTrueTruePassed
reverse relativeTrueTruePassed
negative valuesTrueTruePassed
disjoint tolerancesTrueFalseFailed
ordinary apartFalseFalsePassed
bad relativeinvalidinvalidPassed
bad absoluteinvalidinvalidPassed

SHA-256 / 043b8ec74240665b957ceecab5e14c8c9e77852dbed4e86c66f7a86c30124f70

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(a,b,rel_tol,abs_tol):
    if rel_tol<0 or abs_tol<0: return 'invalid'
    if a==b: return True
    if not math.isfinite(a) or not math.isfinite(b): return False
    difference=abs(a-b)
    relative=rel_tol*max(abs(a),abs(b))
    return difference<=2*max(abs_tol,relative)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal infinity', solve(math.inf,math.inf,1e-9,0.0), True)
check('opposite infinity', solve(math.inf,-math.inf,1e-9,0.0), False)
check('nan', solve(math.nan,math.nan,1.0,1.0), False)
check('absolute zero', solve(0.0,N*1e-9,0.0,N*1e-9), True)
check('relative boundary', solve(float(N),float(N*2),0.5,0.0), True)
check('reverse relative', solve(float(N*2),float(N),0.5,0.0), True)
check('negative values', solve(-float(N),-float(N*2),0.5,0.0), True)
check('disjoint tolerances', solve(0.0,1.5,0.5,1.0), False)
check('ordinary apart', solve(float(N),float(N+1),1e-6,0.0), False)
check('bad relative', solve(1.0,1.0,-1.0,0.0), "invalid")
check('bad absolute', solve(1.0,1.0,0.0,-1.0), "invalid")
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
equal infinityTrueTruePassed
opposite infinityFalseFalsePassed
nanFalseFalsePassed
absolute zeroTrueTruePassed
relative boundaryTrueTruePassed
reverse relativeTrueTruePassed
negative valuesTrueTruePassed
disjoint tolerancesTrueFalseFailed
ordinary apartFalseFalsePassed
bad relativeinvalidinvalidPassed
bad absoluteinvalidinvalidPassed

SHA-256 / 5369f68a370d25794252f9f3dbbbd681c34d5cf1590720ddd12b126407b8741e

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 11 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

Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. 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:39:42.977273+00:00.

Case digest / e3cd7c6fe916a87e8a3fb6c2ee1eddde1dc2aefec511ec83abcbab8c18764f74