FAILURE MAP
← Case archive

FA-16761 / Floating-point arithmetic / Open access

Sine-pi fails to reflect the near-integer positive residual · case 01

Sine-pi fails to reflect the near-integer positive residual.

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

ROOT CAUSE

Sine-pi fails to reflect the near-integer positive residual. The faulty expression is if r>0.5: r=r.

VERIFIED REPAIR

Apply the contract at this fault site using if r>0.5: r=1-r.

Unsuccessful approach: The attempted local correction if r>0.5: r=r-1 still violates the explicit regression fixtures.

Case contract

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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
remainder sign reversal00Passed
positive integer00Passed
negative integer-0-0Passed
half positive11Passed
half negative-1-1Passed
quarter0.707106781190.70710678119Passed
three quarters0.707106781190.70710678119Passed
negative three quarters-0.70710678119-0.70710678119Passed
large integer00Passed
negative zero-0-0Passed
near integer2.8573924409e-122.8572618736e-12Failed

SHA-256 / 42b5dc10dae5fd78b31511fd5e95947b07792b5e2c73701b361299f1d735b4df

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,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=r-1
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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
remainder sign reversal00Passed
positive integer00Passed
negative integer-0-0Passed
half positive11Passed
half negative-1-1Passed
quarter0.707106781190.70710678119Passed
three quarters-0.707106781190.70710678119Failed
negative three quarters-0.70710678119-0.70710678119Passed
large integer00Passed
negative zero-0-0Passed
near integer-2.8572618736e-122.8572618736e-12Failed

SHA-256 / 6a567d87c6e5ce57b1799d7ed7dbac35a5364f92fd8c4a03719fde0230076936

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,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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
remainder sign reversal00Passed
positive integer00Passed
negative integer-0-0Passed
half positive11Passed
half negative-1-1Passed
quarter0.707106781190.70710678119Passed
three quarters0.707106781190.70710678119Passed
negative three quarters-0.70710678119-0.70710678119Passed
large integer00Passed
negative zero-0-0Passed
near integer2.8572618736e-122.8572618736e-12Passed

SHA-256 / 3883052a73cc4a94e83ee2a606013d3902d006c18fde9276e67cf26477619097

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

Case digest / c46a98d68b3f0b00886188afe11c41208f7b0ad5cd1f3cc39a6953e1861ae718