FAILURE MAP
← Case archive

FA-16816 / Floating-point arithmetic / Open access

Tangent-pi measures pole distance from an integer · case 01

Tangent-pi measures pole distance from an integer.

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

ROOT CAUSE

Tangent-pi measures pole distance from an integer. The faulty expression is d=1-abs(r).

VERIFIED REPAIR

Apply the contract at this fault site using d=0.5-abs(r).

Unsuccessful approach: The attempted local correction d=abs(r) still violates the explicit regression fixtures.

Case contract

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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:
        r=math.remainder(x,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=1-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        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('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "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
integer00Passed
negative integer-0-0Passed
positive quarter11Passed
negative quarter-1-1Passed
polepolepolePassed
negative polepolepolePassed
near positive pole2.8253475241e-153.583850712e+14Failed
near negative pole-2.8253475241e-15-3.583850712e+14Failed
beyond pole-1-1Passed
huge integer00Passed

SHA-256 / dc8d67a32743d5fc57b930fdbf38cfdbd1f61e748aed2161ee23da5ec7994aab

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:
        r=math.remainder(x,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        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('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "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
integer00Passed
negative integer-0-0Passed
positive quarter11Passed
negative quarter-1-1Passed
polepolepolePassed
negative polepolepolePassed
near positive pole2.947812204e-153.583850712e+14Failed
near negative pole-2.947812204e-15-3.583850712e+14Failed
beyond pole-1-1Passed
huge integer00Passed

SHA-256 / b253c41beda8093fda7d5cbfcdeaa9b15e9bc3e5d2a30d5ed0d8fa7c21a959c2

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:
        r=math.remainder(x,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        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('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "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
integer00Passed
negative integer-0-0Passed
positive quarter11Passed
negative quarter-1-1Passed
polepolepolePassed
negative polepolepolePassed
near positive pole3.583850712e+143.583850712e+14Passed
near negative pole-3.583850712e+14-3.583850712e+14Passed
beyond pole-1-1Passed
huge integer00Passed

SHA-256 / 7bb38e60b67d2bd67d075181f824cc22d182debd28495d76f9e37878be73bfdd

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

Case digest / 8d6d5aa4da1234563397f6a40178cf0e6ef27c38b117b9a1dc9926765dce5cd5