FAILURE MAP
← Case archive

FA-16366 / Floating-point arithmetic / Open access

Cosine decrement fails to square the half-angle sine · case 01

Cosine decrement fails to square the half-angle sine.

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

ROOT CAUSE

Cosine decrement fails to square the half-angle sine. The faulty expression is result=-2*s.

VERIFIED REPAIR

Apply the contract at this fault site using result=-2*s*s.

Unsuccessful approach: The attempted local correction result=-2*abs(s) 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
        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-9.3132257462e-10-4.3368086899e-19Failed
negative tiny9.3132257462e-10-4.3368086899e-19Failed
normal-0.95885107721-0.45969769413Failed
negative normal0.95885107721-0.45969769413Failed
zero-0-0Passed
pi-2-2Passed
half pi-1.4142135624-1Failed

SHA-256 / 6bf906d92a8def76d1e16830396da07a4b3f37ace033bb88d8abfc70efc2aa70

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*abs(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-9.3132257462e-10-4.3368086899e-19Failed
negative tiny-9.3132257462e-10-4.3368086899e-19Failed
normal-0.95885107721-0.45969769413Failed
negative normal-0.95885107721-0.45969769413Failed
zero-0-0Passed
pi-2-2Passed
half pi-1.4142135624-1Failed

SHA-256 / f0811d0574c5d4cb99c3d39ec08964eb8392640fd39a5d33351c946f7f32fee6

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

Case digest / ba592ff714e126b983d669e62a5dde912c809fa5f74c9c178e8ed3e29829c84b