FA-16206 / Floating-point arithmetic / Open access
Inverse tangent loses tiny input in a logarithmic ratio · case 01
Inverse tangent loses tiny input in a logarithmic ratio.
ROOT CAUSE
Inverse tangent loses tiny input in a logarithmic ratio. The faulty expression is result=0.5*math.log((1+a)/(1-a)).
VERIFIED REPAIR
Apply the contract at this fault site using result=0.5*math.log1p(2*a/(1-a)).
Unsuccessful approach: The attempted local correction result=0.5*math.log(max((1+a)/(1-a),1.0)) still violates the explicit regression fixtures.
Case contract
Evaluate inverse hyperbolic tangent on [-1,1], with signed infinite endpoints and a domain marker outside. 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 abs(x)>1: return 'domain'
if x==1: return '+infinity'
if x==-1: return '-infinity'
if x==0: return render(x)
a=abs(x)
result=0.5*math.log((1+a)/(1-a))
return render(math.copysign(result,x))
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-60))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-60))
check('normal', solve(0.125*N), render(math.atanh(0.125*N)))
check('negative normal', solve(-0.125*N), render(math.atanh(-0.125*N)))
check('positive endpoint', solve(1.0), "+infinity")
check('negative endpoint', solve(-1.0), "-infinity")
check('invalid', solve(1.0+N), "domain")
check('negative zero', solve(-0.0), "-0")
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 |
|---|---|---|---|
| tiny positive | 0 | 8.6736173799e-19 | Failed |
| tiny negative | -0 | -8.6736173799e-19 | Failed |
| normal | 0.12565721414 | 0.12565721414 | Passed |
| negative normal | -0.12565721414 | -0.12565721414 | Passed |
| positive endpoint | +infinity | +infinity | Passed |
| negative endpoint | -infinity | -infinity | Passed |
| invalid | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
SHA-256 / b7f485873d78517f54c1b07d0ec2b2339bc4d9b7269074ff727dfff9394ee4b0
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 abs(x)>1: return 'domain'
if x==1: return '+infinity'
if x==-1: return '-infinity'
if x==0: return render(x)
a=abs(x)
result=0.5*math.log(max((1+a)/(1-a),1.0))
return render(math.copysign(result,x))
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-60))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-60))
check('normal', solve(0.125*N), render(math.atanh(0.125*N)))
check('negative normal', solve(-0.125*N), render(math.atanh(-0.125*N)))
check('positive endpoint', solve(1.0), "+infinity")
check('negative endpoint', solve(-1.0), "-infinity")
check('invalid', solve(1.0+N), "domain")
check('negative zero', solve(-0.0), "-0")
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 |
|---|---|---|---|
| tiny positive | 0 | 8.6736173799e-19 | Failed |
| tiny negative | -0 | -8.6736173799e-19 | Failed |
| normal | 0.12565721414 | 0.12565721414 | Passed |
| negative normal | -0.12565721414 | -0.12565721414 | Passed |
| positive endpoint | +infinity | +infinity | Passed |
| negative endpoint | -infinity | -infinity | Passed |
| invalid | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
SHA-256 / 7a5aac5662ac9630c4aab84e7fa3e1638101a79f650f95db18a97c0d94de1620
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 abs(x)>1: return 'domain'
if x==1: return '+infinity'
if x==-1: return '-infinity'
if x==0: return render(x)
a=abs(x)
result=0.5*math.log1p(2*a/(1-a))
return render(math.copysign(result,x))
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-60))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-60))
check('normal', solve(0.125*N), render(math.atanh(0.125*N)))
check('negative normal', solve(-0.125*N), render(math.atanh(-0.125*N)))
check('positive endpoint', solve(1.0), "+infinity")
check('negative endpoint', solve(-1.0), "-infinity")
check('invalid', solve(1.0+N), "domain")
check('negative zero', solve(-0.0), "-0")
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 |
|---|---|---|---|
| tiny positive | 8.6736173799e-19 | 8.6736173799e-19 | Passed |
| tiny negative | -8.6736173799e-19 | -8.6736173799e-19 | Passed |
| normal | 0.12565721414 | 0.12565721414 | Passed |
| negative normal | -0.12565721414 | -0.12565721414 | Passed |
| positive endpoint | +infinity | +infinity | Passed |
| negative endpoint | -infinity | -infinity | Passed |
| invalid | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
SHA-256 / a09958c68ceb529aadf5c8ff07b6328951ccdd723403737abd521529a5a576d4
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.049960+00:00.
Case digest / e0b931de3fc19c2e811a772e58c451430c2baeebddf4422e9042495fb5f9e9bb