FA-16371 / Floating-point arithmetic / Open access
Cosine decrement returns a positive half-angle square · case 01
Cosine decrement returns a positive half-angle square.
ROOT CAUSE
Cosine decrement returns a positive half-angle square. The faulty expression is result=2*s*s.
VERIFIED REPAIR
Apply the contract at this fault site using result=-2*s*s.
Unsuccessful approach: The attempted local correction result=-s*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*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny | 4.3368086899e-19 | -4.3368086899e-19 | Failed |
| negative tiny | 4.3368086899e-19 | -4.3368086899e-19 | Failed |
| normal | 0.45969769413 | -0.45969769413 | Failed |
| negative normal | 0.45969769413 | -0.45969769413 | Failed |
| zero | -0 | -0 | Passed |
| pi | 2 | -2 | Failed |
| half pi | 1 | -1 | Failed |
SHA-256 / 1cadae1ad04f419cb84a057beab0523b0099787e81c99dbf286864fceb956751
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=-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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny | -2.168404345e-19 | -4.3368086899e-19 | Failed |
| negative tiny | -2.168404345e-19 | -4.3368086899e-19 | Failed |
| normal | -0.22984884707 | -0.45969769413 | Failed |
| negative normal | -0.22984884707 | -0.45969769413 | Failed |
| zero | -0 | -0 | Passed |
| pi | -1 | -2 | Failed |
| half pi | -0.5 | -1 | Failed |
SHA-256 / 311e68eeef9f78e3cb3159cd261281fb38389c385e3cb0b7f57bd0fb47a1c587
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny | -4.3368086899e-19 | -4.3368086899e-19 | Passed |
| negative tiny | -4.3368086899e-19 | -4.3368086899e-19 | Passed |
| normal | -0.45969769413 | -0.45969769413 | Passed |
| negative normal | -0.45969769413 | -0.45969769413 | Passed |
| zero | -0 | -0 | Passed |
| pi | -2 | -2 | Passed |
| half pi | -1 | -1 | Passed |
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.663490+00:00.
Case digest / b6a08fde77c38a14a5d38553cb8f73e0623f890afa8d91b0e5e52596e74e63d8