FAILURE MAP
← Case archive

FA-16811 / Floating-point arithmetic / Open access

Tangent-pi treats the finite rounded tangent at a pole as valid · case 01

Tangent-pi treats the finite rounded tangent at a pole as valid.

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

ROOT CAUSE

Tangent-pi treats the finite rounded tangent at a pole as valid. The faulty expression is if abs(r)==0.5: return render(math.tan(math.pi*r)).

VERIFIED REPAIR

Apply the contract at this fault site using if abs(r)==0.5: return 'pole'.

Unsuccessful approach: The attempted local correction if abs(r)==0.5: return '+infinity' 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 render(math.tan(math.pi*r))
        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
pole-1.6331239353e+16poleFailed
negative pole1.6331239353e+16poleFailed
near positive pole3.583850712e+143.583850712e+14Passed
near negative pole-3.583850712e+14-3.583850712e+14Passed
beyond pole-1-1Passed
huge integer00Passed

SHA-256 / 8afeed5d297862851a76139c04b8c8ec9500f4e1c60b6c754473345fd3f46228

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 '+infinity'
        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
pole+infinitypoleFailed
negative pole+infinitypoleFailed
near positive pole3.583850712e+143.583850712e+14Passed
near negative pole-3.583850712e+14-3.583850712e+14Passed
beyond pole-1-1Passed
huge integer00Passed

SHA-256 / d28005c0daa7dc497a8ea9bbfa676675f816d768beeb5144180f7cff6cc4b479

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

Case digest / 8877018f6c59f276169456a5066ebc81ca282dc4ecd56680a1680eed60d3dba8