FA-16261 / Floating-point arithmetic / Open access
Inverse cosine overflows while squaring a finite input · case 01
Inverse cosine overflows while squaring a finite input.
ROOT CAUSE
Inverse cosine overflows while squaring a finite input. The faulty expression is result=math.log(x+math.sqrt(x*x-1)).
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(min(x+math.sqrt(x*x-1),1e308)) 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+math.sqrt(x*x-1))
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 | +infinity | 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 / 1b5eb607914058f15e35cc577b010c0c85d5e15cad09cb514f5dd6b6c4d5e791
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(min(x+math.sqrt(x*x-1),1e308))
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 | 709.19620864 | 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 / 9c89aa37230fbd9488f510903b12ee0298bd3197ff06fa6dc892bedb28d53ed0
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.705722+00:00.
Case digest / 7c19c9526f6fe8fd6e0d0630aa5c9aaf1230fca5d842ce9c44e383026fb01175