FAILURE MAP
← Case archive

FA-16376 / Floating-point arithmetic / Open access

Cosine decrement violates its limiting zero sign · case 01

Cosine decrement violates its limiting zero sign.

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

ROOT CAUSE

Cosine decrement violates its limiting zero sign. The faulty expression is if x==0: return '0'.

VERIFIED REPAIR

Apply the contract at this fault site using if x==0: return '-0'.

Unsuccessful approach: The attempted local correction if x==0: return render(x) still violates the explicit regression fixtures.

Case contract

Evaluate cos(x)-1 for finite x without cancellation using the half-angle identity. 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:
        if x==0: return '0'
        s=math.sin(x/2)
        result=-2*s*s
        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('tiny', solve(N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('negative tiny', solve(-N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('normal', solve(float(N)), render(-2*math.sin(N/2)**2))
check('negative normal', solve(-float(N)), render(-2*math.sin(N/2)**2))
check('zero', solve(0.0), "-0")
check('pi', solve(math.pi), "-2")
check('half pi', solve(math.pi/2), "-1")
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
tiny-4.3368086899e-19-4.3368086899e-19Passed
negative tiny-4.3368086899e-19-4.3368086899e-19Passed
normal-0.45969769413-0.45969769413Passed
negative normal-0.45969769413-0.45969769413Passed
zero0-0Failed
pi-2-2Passed
half pi-1-1Passed

SHA-256 / fbf56ac6c5ea50a07ba5245fcc71c06b6e7ce5ff2d5a2a70763d9598267097be

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:
        if x==0: return render(x)
        s=math.sin(x/2)
        result=-2*s*s
        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('tiny', solve(N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('negative tiny', solve(-N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('normal', solve(float(N)), render(-2*math.sin(N/2)**2))
check('negative normal', solve(-float(N)), render(-2*math.sin(N/2)**2))
check('zero', solve(0.0), "-0")
check('pi', solve(math.pi), "-2")
check('half pi', solve(math.pi/2), "-1")
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
tiny-4.3368086899e-19-4.3368086899e-19Passed
negative tiny-4.3368086899e-19-4.3368086899e-19Passed
normal-0.45969769413-0.45969769413Passed
negative normal-0.45969769413-0.45969769413Passed
zero0-0Failed
pi-2-2Passed
half pi-1-1Passed

SHA-256 / 1a5a1eb847fda147defacf953bc58c3ec628a6d0fe15f349e024206c9b8ec9d9

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:
        if x==0: return '-0'
        s=math.sin(x/2)
        result=-2*s*s
        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('tiny', solve(N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('negative tiny', solve(-N*2.0**-30), render(-0.5*(N*2.0**-30)**2))
check('normal', solve(float(N)), render(-2*math.sin(N/2)**2))
check('negative normal', solve(-float(N)), render(-2*math.sin(N/2)**2))
check('zero', solve(0.0), "-0")
check('pi', solve(math.pi), "-2")
check('half pi', solve(math.pi/2), "-1")
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
tiny-4.3368086899e-19-4.3368086899e-19Passed
negative tiny-4.3368086899e-19-4.3368086899e-19Passed
normal-0.45969769413-0.45969769413Passed
negative normal-0.45969769413-0.45969769413Passed
zero-0-0Passed
pi-2-2Passed
half pi-1-1Passed

SHA-256 / 574c04d51a1b28a816c764b6b202eef5b0e3c80f7a3240d643a5f67654f8271c

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

Case digest / 922101ba8a9dbc6b931503042f913e4f1b3ef0764e7605a18901bb2577d5638c