FAILURE MAP
← Case archive

FA-17081 / Floating-point arithmetic / Open access

Closeness excludes values exactly at tolerance · case 01

Closeness excludes values exactly at tolerance.

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

ROOT CAUSE

Closeness excludes values exactly at tolerance. The faulty expression is return difference<max(abs_tol,relative).

VERIFIED REPAIR

Apply the contract at this fault site using return difference<=max(abs_tol,relative).

Unsuccessful approach: The attempted local correction return difference<=min(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<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 zeroFalseTrueFailed
relative boundaryFalseTrueFailed
reverse relativeFalseTrueFailed
negative valuesFalseTrueFailed
disjoint tolerancesFalseFalsePassed
ordinary apartFalseFalsePassed
bad relativeinvalidinvalidPassed
bad absoluteinvalidinvalidPassed

SHA-256 / 64b2babbcacf37d6290f720e22e028ac81195fed9d336969af69faaf769fd17b

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<=min(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 zeroFalseTrueFailed
relative boundaryFalseTrueFailed
reverse relativeFalseTrueFailed
negative valuesFalseTrueFailed
disjoint tolerancesFalseFalsePassed
ordinary apartFalseFalsePassed
bad relativeinvalidinvalidPassed
bad absoluteinvalidinvalidPassed

SHA-256 / acbae5b7fd30749737ce77bc05e71dd2d5e2b01946941f580573ec931bf829c9

3 / The verified repair

Exit 0
"""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<=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 tolerancesFalseFalsePassed
ordinary apartFalseFalsePassed
bad relativeinvalidinvalidPassed
bad absoluteinvalidinvalidPassed

SHA-256 / d99becf37aff8567b546848e57dd7b96eb8a46f9a6359a7133a912bf628d5c9f

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.830454+00:00.

Case digest / ffecd84a48d543876006f32013f4b43f080e148b7553c5521fd28a4092482d4f