FA-17031 / Floating-point arithmetic / Open access
Log ratio materializes an overflowing or underflowing quotient · case 01
Log ratio materializes an overflowing or underflowing quotient.
ROOT CAUSE
Log ratio materializes an overflowing or underflowing quotient. The faulty expression is result=math.log(a/b).
THE FAILURE
Log ratio materializes an overflowing or underflowing quotient. The faulty expression is result=math.log(a/b).
Unsuccessful approach: The attempted local correction result=math.log(max(min(a/b,1e300),1e-300)) 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/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 | +infinity | 1381.5510558 | Failed |
| underflowing quotient | arithmetic-error | -1381.5510558 | Failed |
| 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 / 8c0d175d601e4465da4db946c7e190a3157a50061f1c522dd360a4ba322e1b26
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 'domain'
if a==b: return '0'
r=(a-b)/b
if abs(r)<0.5:
result=math.log1p(r)
else:
result=math.log(max(min(a/b,1e300),1e-300))
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 | 690.7755279 | 1381.5510558 | Failed |
| underflowing quotient | -690.7755279 | -1381.5510558 | Failed |
| 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 / ea3d85f4f9cf3ceec8b74d998d5d5648361ac2b238676492fee763e85d582b38
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
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 / eaedc79e5420951f2a5f73df05747787b8fb9272a305184b47d547be87aa9df1