FA-17051 / Floating-point arithmetic / Open access
Log ratio accepts zero endpoints as ordinary positives · case 01
Log ratio accepts zero endpoints as ordinary positives.
ROOT CAUSE
Log ratio accepts zero endpoints as ordinary positives. The faulty expression is if a<0 or b<0: return 'domain'.
VERIFIED REPAIR
Apply the contract at this fault site using if a<=0 or b<=0: return 'domain'.
Unsuccessful approach: The attempted local correction if a<=0 or b<=0: return '-infinity' still violates the explicit regression fixtures.
Case contract
Evaluate log(a/b) for positive finite endpoints without overflowing an intermediate quotient and without cancellation for nearby operands. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.
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
def render(x):
if math.isnan(x): return 'nan'
if math.isinf(x): return '-infinity' if x<0 else '+infinity'
return format(x,'.11g')
N = 1
observations = []
def solve(a,b):
try:
if a<0 or b<0: return 'domain'
if a==b: return '0'
r=(a-b)/b
if abs(r)<0.5:
result=math.log1p(r)
else:
result=math.log(a)-math.log(b)
return render(result)
except (ValueError, OverflowError, ZeroDivisionError, TypeError):
return "arithmetic-error"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))
check('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))
check('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))
check('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))
check('normal', solve(float(N+1),1.0), render(math.log(N+1)))
check('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))
check('equal', solve(float(N),float(N)), "0")
check('invalid', solve(0.0,float(N)), "domain")
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflowing quotient | 1381.5510558 | 1381.5510558 | Passed |
| underflowing quotient | -1381.5510558 | -1381.5510558 | Passed |
| nearby moderate | 0.11778303566 | 0.11778303566 | Passed |
| nearby large | 1.9426688922e-16 | 1.9426688922e-16 | Passed |
| normal | 0.69314718056 | 0.69314718056 | Passed |
| reverse | -0.69314718056 | -0.69314718056 | Passed |
| equal | 0 | 0 | Passed |
| invalid | arithmetic-error | domain | Failed |
SHA-256 / 2532d81984d87f8006ade55349b0fe9ec622040e8ce94233048d46c3a23393df
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
if math.isnan(x): return 'nan'
if math.isinf(x): return '-infinity' if x<0 else '+infinity'
return format(x,'.11g')
N = 1
observations = []
def solve(a,b):
try:
if a<=0 or b<=0: return '-infinity'
if a==b: return '0'
r=(a-b)/b
if abs(r)<0.5:
result=math.log1p(r)
else:
result=math.log(a)-math.log(b)
return render(result)
except (ValueError, OverflowError, ZeroDivisionError, TypeError):
return "arithmetic-error"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))
check('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))
check('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))
check('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))
check('normal', solve(float(N+1),1.0), render(math.log(N+1)))
check('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))
check('equal', solve(float(N),float(N)), "0")
check('invalid', solve(0.0,float(N)), "domain")
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflowing quotient | 1381.5510558 | 1381.5510558 | Passed |
| underflowing quotient | -1381.5510558 | -1381.5510558 | Passed |
| nearby moderate | 0.11778303566 | 0.11778303566 | Passed |
| nearby large | 1.9426688922e-16 | 1.9426688922e-16 | Passed |
| normal | 0.69314718056 | 0.69314718056 | Passed |
| reverse | -0.69314718056 | -0.69314718056 | Passed |
| equal | 0 | 0 | Passed |
| invalid | -infinity | domain | Failed |
SHA-256 / 9add15ff384c78abf4a45cf44c3a120383d88778893272045e49b61a2dfc31b1
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
if math.isnan(x): return 'nan'
if math.isinf(x): return '-infinity' if x<0 else '+infinity'
return format(x,'.11g')
N = 1
observations = []
def solve(a,b):
try:
if a<=0 or b<=0: return 'domain'
if a==b: return '0'
r=(a-b)/b
if abs(r)<0.5:
result=math.log1p(r)
else:
result=math.log(a)-math.log(b)
return render(result)
except (ValueError, OverflowError, ZeroDivisionError, TypeError):
return "arithmetic-error"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))
check('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))
check('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))
check('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))
check('normal', solve(float(N+1),1.0), render(math.log(N+1)))
check('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))
check('equal', solve(float(N),float(N)), "0")
check('invalid', solve(0.0,float(N)), "domain")
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflowing quotient | 1381.5510558 | 1381.5510558 | Passed |
| underflowing quotient | -1381.5510558 | -1381.5510558 | Passed |
| nearby moderate | 0.11778303566 | 0.11778303566 | Passed |
| nearby large | 1.9426688922e-16 | 1.9426688922e-16 | Passed |
| normal | 0.69314718056 | 0.69314718056 | Passed |
| reverse | -0.69314718056 | -0.69314718056 | Passed |
| equal | 0 | 0 | Passed |
| invalid | domain | domain | Passed |
SHA-256 / 7da1be31e2ee6da6c7190c7986b0341a1ff43375807b435544d6a8b7467aa487
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.354580+00:00.
Case digest / bc9271fffcd08f7e957387701b389ab58a79d71f7108d49333fd661f76640e50