FAILURE MAP
← Case archive

FA-16226 / Floating-point arithmetic / Open access

Inverse tangent uses one plus magnitude in its rationalization · case 01

Inverse tangent uses one plus magnitude in its rationalization.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Inverse tangent uses one plus magnitude in its rationalization. The faulty expression is result=0.5*math.log1p(2*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=math.log1p(a) 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.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 fixtureActualExpectedOutcome
tiny positive8.6736173799e-198.6736173799e-19Passed
tiny negative-8.6736173799e-19-8.6736173799e-19Passed
normal0.100335347730.12565721414Failed
negative normal-0.10033534773-0.12565721414Failed
positive endpoint+infinity+infinityPassed
negative endpoint-infinity-infinityPassed
invaliddomaindomainPassed
negative zero-0-0Passed

SHA-256 / b14c62e5d20f290f3a6b440c9dc38fc6fc690ca69840a34b95fd593cf7d7fa80

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=math.log1p(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 fixtureActualExpectedOutcome
tiny positive8.6736173799e-198.6736173799e-19Passed
tiny negative-8.6736173799e-19-8.6736173799e-19Passed
normal0.117783035660.12565721414Failed
negative normal-0.11778303566-0.12565721414Failed
positive endpoint+infinity+infinityPassed
negative endpoint-infinity-infinityPassed
invaliddomaindomainPassed
negative zero-0-0Passed

SHA-256 / 893f02076fd7184b31cf99a73b1d1128e3f7eeffc3e309f1f5c9d0a296c11fdc

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 fixtureActualExpectedOutcome
tiny positive8.6736173799e-198.6736173799e-19Passed
tiny negative-8.6736173799e-19-8.6736173799e-19Passed
normal0.125657214140.12565721414Passed
negative normal-0.12565721414-0.12565721414Passed
positive endpoint+infinity+infinityPassed
negative endpoint-infinity-infinityPassed
invaliddomaindomainPassed
negative zero-0-0Passed

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.357219+00:00.

Case digest / 169c26538f3b1c7a7166f6c82c923f755819f59a7f8dc4d9600d862e48f9ace3