FA-16266 / Floating-point arithmetic / Open access
Inverse cosine forgets the factor of two at large magnitude · case 01
Inverse cosine forgets the factor of two at large magnitude.
ROOT CAUSE
Inverse cosine forgets the factor of two at large magnitude. The faulty expression is result=math.log(x).
VERIFIED REPAIR
Apply the contract at this fault site using result=math.log(x)+math.log(2).
Unsuccessful approach: The attempted local correction result=math.log(2)*math.log(x) still violates the explicit regression fixtures.
Case contract
Evaluate inverse hyperbolic cosine for finite x>=1. Use logarithmic scaling for huge inputs and a log1p expression near one. 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(x):
try:
if x<1: return 'domain'
if x==1: return '0'
if x>1e150:
result=math.log(x)
else:
t=x-1
result=math.log1p(t+math.sqrt(t*(x+1)))
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('fixed near one', solve(1+2.0**-50), render(math.acosh(1+2.0**-50)))
check('near one', solve(1+N*2.0**-50), render(math.acosh(1+N*2.0**-50)))
check('huge', solve(N*1e300), render(math.acosh(N*1e300)))
check('normal', solve(1.0+N), render(math.acosh(1.0+N)))
check('endpoint', solve(1.0), "0")
check('invalid', solve(0.0), "domain")
check('negative', solve(-float(N)), "domain")
check('mid', solve(1.5), render(math.acosh(1.5)))
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 |
|---|---|---|---|
| fixed near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| huge | 690.7755279 | 691.46867508 | Failed |
| normal | 1.3169578969 | 1.3169578969 | Passed |
| endpoint | 0 | 0 | Passed |
| invalid | domain | domain | Passed |
| negative | domain | domain | Passed |
| mid | 0.96242365012 | 0.96242365012 | Passed |
SHA-256 / 10b09f34dbfc662249ae614f93951e022ccda0f08ddc322e769a77cdb40c6cf5
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(x):
try:
if x<1: return 'domain'
if x==1: return '0'
if x>1e150:
result=math.log(2)*math.log(x)
else:
t=x-1
result=math.log1p(t+math.sqrt(t*(x+1)))
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('fixed near one', solve(1+2.0**-50), render(math.acosh(1+2.0**-50)))
check('near one', solve(1+N*2.0**-50), render(math.acosh(1+N*2.0**-50)))
check('huge', solve(N*1e300), render(math.acosh(N*1e300)))
check('normal', solve(1.0+N), render(math.acosh(1.0+N)))
check('endpoint', solve(1.0), "0")
check('invalid', solve(0.0), "domain")
check('negative', solve(-float(N)), "domain")
check('mid', solve(1.5), render(math.acosh(1.5)))
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 |
|---|---|---|---|
| fixed near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| huge | 478.80910956 | 691.46867508 | Failed |
| normal | 1.3169578969 | 1.3169578969 | Passed |
| endpoint | 0 | 0 | Passed |
| invalid | domain | domain | Passed |
| negative | domain | domain | Passed |
| mid | 0.96242365012 | 0.96242365012 | Passed |
SHA-256 / 08fe2efe62969cee7ff67425f07353e7628c3f9cc1d8f37b4b62965037ed5993
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(x):
try:
if x<1: return 'domain'
if x==1: return '0'
if x>1e150:
result=math.log(x)+math.log(2)
else:
t=x-1
result=math.log1p(t+math.sqrt(t*(x+1)))
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('fixed near one', solve(1+2.0**-50), render(math.acosh(1+2.0**-50)))
check('near one', solve(1+N*2.0**-50), render(math.acosh(1+N*2.0**-50)))
check('huge', solve(N*1e300), render(math.acosh(N*1e300)))
check('normal', solve(1.0+N), render(math.acosh(1.0+N)))
check('endpoint', solve(1.0), "0")
check('invalid', solve(0.0), "domain")
check('negative', solve(-float(N)), "domain")
check('mid', solve(1.5), render(math.acosh(1.5)))
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 |
|---|---|---|---|
| fixed near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| near one | 4.2146848511e-08 | 4.2146848511e-08 | Passed |
| huge | 691.46867508 | 691.46867508 | Passed |
| normal | 1.3169578969 | 1.3169578969 | Passed |
| endpoint | 0 | 0 | Passed |
| invalid | domain | domain | Passed |
| negative | domain | domain | Passed |
| mid | 0.96242365012 | 0.96242365012 | Passed |
SHA-256 / 137bdac84d7b5baab52f9454e9710a9b859cddef10da835f53f1c155ed9692c1
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:34.705402+00:00.
Case digest / 66799d19e2626fb64ee6dc6b74ee5f4dd5c273084ff1467973cbfdec1db88d3a