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.
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| integer | 6.1232339957e-17 | 0 | Failed |
| negative integer | -6.1232339957e-17 | -0 | Failed |
| positive quarter | 1 | 1 | Passed |
| negative quarter | -1 | -1 | Passed |
| pole | 8.1656196766e+15 | pole | Failed |
| negative pole | -8.1656196766e+15 | pole | Failed |
| near positive pole | 3.583850712e+14 | 3.583850712e+14 | Passed |
| near negative pole | -3.583850712e+14 | -3.583850712e+14 | Passed |
| beyond pole | 1 | -1 | Failed |
| huge integer | 1.6254482349 | 0 | Failed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| integer | 0 | 0 | Passed |
| negative integer | -0 | -0 | Passed |
| positive quarter | 1 | 1 | Passed |
| negative quarter | -1 | -1 | Passed |
| pole | pole | pole | Passed |
| negative pole | pole | pole | Passed |
| near positive pole | 3.3730359642e+14 | 3.583850712e+14 | Failed |
| near negative pole | -3.3730359642e+14 | -3.583850712e+14 | Failed |
| beyond pole | -1 | -1 | Passed |
| huge integer | 1.1578212823 | 0 | Failed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| integer | 0 | 0 | Passed |
| negative integer | -0 | -0 | Passed |
| positive quarter | 1 | 1 | Passed |
| negative quarter | -1 | -1 | Passed |
| pole | pole | pole | Passed |
| negative pole | pole | pole | Passed |
| near positive pole | 3.583850712e+14 | 3.583850712e+14 | Passed |
| near negative pole | -3.583850712e+14 | -3.583850712e+14 | Passed |
| beyond pole | -1 | -1 | Passed |
| huge integer | 0 | 0 | Passed |
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