FAILURE MAP
← Case archive

FA-16361 / Floating-point arithmetic / Open access

Cosine decrement forgets half-angle reduction · case 01

Cosine decrement forgets half-angle reduction.

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

ROOT CAUSE

Cosine decrement forgets half-angle reduction. The faulty expression is s=math.sin(x).

VERIFIED REPAIR

Apply the contract at this fault site using s=math.sin(x/2).

Unsuccessful approach: The attempted local correction s=math.sin(x)/2 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)
        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-1.734723476e-18-4.3368086899e-19Failed
negative tiny-1.734723476e-18-4.3368086899e-19Failed
normal-1.4161468365-0.45969769413Failed
negative normal-1.4161468365-0.45969769413Failed
zero-0-0Passed
pi-2.9995195653e-32-2Failed
half pi-2-1Failed

SHA-256 / 28e2314d46e11c76f9593c2db2206271cdd6ac2ff02ef4aaac17f1c590f40c34

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 '-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.35403670914-0.45969769413Failed
negative normal-0.35403670914-0.45969769413Failed
zero-0-0Passed
pi-7.4987989133e-33-2Failed
half pi-0.5-1Failed

SHA-256 / 8128e55f6a1c7b75577061ca5d5f40440dcbfbf7414751816d83dfdc9cab5b66

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

Case digest / 0accdeb5c63b327a34656f173bf4a8263aeab0cf4181aa20b9025d6cf5e53728