FAILURE MAP
← Case archive

FA-16806 / Floating-point arithmetic / Open access

Tangent-pi multiplies the unreduced input by pi · case 01

Tangent-pi multiplies the unreduced input by pi.

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

ROOT CAUSE

Tangent-pi multiplies the unreduced input by pi. The faulty expression is r=x.

VERIFIED REPAIR

Apply the contract at this fault site using r=math.remainder(x,1.0).

Unsuccessful approach: The attempted local correction r=math.remainder(math.pi*x,math.pi)/math.pi 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=x
        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
integer6.1232339957e-170Failed
negative integer-6.1232339957e-17-0Failed
positive quarter11Passed
negative quarter-1-1Passed
pole8.1656196766e+15poleFailed
negative pole-8.1656196766e+15poleFailed
near positive pole3.583850712e+143.583850712e+14Passed
near negative pole-3.583850712e+14-3.583850712e+14Passed
beyond pole1-1Failed
huge integer1.62544823490Failed

SHA-256 / 24a7984255865416f11a8623ceff74b8c95afb8561ea674cda848ba119dfc68d

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(math.pi*x,math.pi)/math.pi
        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.3730359642e+143.583850712e+14Failed
near negative pole-3.3730359642e+14-3.583850712e+14Failed
beyond pole-1-1Passed
huge integer1.15782128230Failed

SHA-256 / 07edc9aac26c2532791c6e5fc2b868694ce3745607c8f69cf28b5d8950fa5013

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

Case digest / 74f69f1f3d8c0b2d649cd30a2408c57501b5df6c2aac69727a5d655d37e11deb