FA-16166 / Floating-point arithmetic / Open access
Softplus evaluates the wrong stabilized branch · case 01
Softplus evaluates the wrong stabilized branch.
ROOT CAUSE
Softplus evaluates the wrong stabilized branch. The faulty expression is if x<0:.
VERIFIED REPAIR
Apply the contract at this fault site using if x>0:.
Unsuccessful approach: The attempted local correction if x==0: still violates the explicit regression fixtures.
Case contract
Evaluate log(1+exp(x)) without overflowing or erasing a small positive tail. 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:
result=x+math.log1p(math.exp(-x))
else:
result=math.log1p(math.exp(x))
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('positive huge', solve(1000.0*N), render(1000.0*N))
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), render(math.log(2)))
check('positive moderate', solve(float(N)), render(math.log1p(math.exp(float(N)))))
check('negative moderate', solve(-float(N)), render(math.log1p(math.exp(-float(N)))))
check('small positive', solve(N*1e-8), render(math.log1p(math.exp(N*1e-8))))
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 |
|---|---|---|---|
| positive huge | arithmetic-error | 1000 | Failed |
| negative tail | 0 | 7.0954741623e-23 | Failed |
| zero | 0.69314718056 | 0.69314718056 | Passed |
| positive moderate | 1.3132616875 | 1.3132616875 | Passed |
| negative moderate | 0.31326168752 | 0.31326168752 | Passed |
| small positive | 0.69314718556 | 0.69314718556 | Passed |
SHA-256 / a3126b578b481cda1fa0912c0b4373865092a9b32707862b7ab5cded3f8f1836
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:
result=x+math.log1p(math.exp(-x))
else:
result=math.log1p(math.exp(x))
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('positive huge', solve(1000.0*N), render(1000.0*N))
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), render(math.log(2)))
check('positive moderate', solve(float(N)), render(math.log1p(math.exp(float(N)))))
check('negative moderate', solve(-float(N)), render(math.log1p(math.exp(-float(N)))))
check('small positive', solve(N*1e-8), render(math.log1p(math.exp(N*1e-8))))
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 |
|---|---|---|---|
| positive huge | arithmetic-error | 1000 | Failed |
| negative tail | 7.0954741623e-23 | 7.0954741623e-23 | Passed |
| zero | 0.69314718056 | 0.69314718056 | Passed |
| positive moderate | 1.3132616875 | 1.3132616875 | Passed |
| negative moderate | 0.31326168752 | 0.31326168752 | Passed |
| small positive | 0.69314718556 | 0.69314718556 | Passed |
SHA-256 / 07dd0dacceecd9ed2689b2eb65cc82dd4ee1370908d6ec93946842969238afd4
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:
result=x+math.log1p(math.exp(-x))
else:
result=math.log1p(math.exp(x))
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('positive huge', solve(1000.0*N), render(1000.0*N))
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), render(math.log(2)))
check('positive moderate', solve(float(N)), render(math.log1p(math.exp(float(N)))))
check('negative moderate', solve(-float(N)), render(math.log1p(math.exp(-float(N)))))
check('small positive', solve(N*1e-8), render(math.log1p(math.exp(N*1e-8))))
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 |
|---|---|---|---|
| positive huge | 1000 | 1000 | Passed |
| negative tail | 7.0954741623e-23 | 7.0954741623e-23 | Passed |
| zero | 0.69314718056 | 0.69314718056 | Passed |
| positive moderate | 1.3132616875 | 1.3132616875 | Passed |
| negative moderate | 0.31326168752 | 0.31326168752 | Passed |
| small positive | 0.69314718556 | 0.69314718556 | Passed |
SHA-256 / b3e0d0ed0bb46c46fb9f2ef65916ed9a364d4676147e96f2f123c6ab89501610
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:33.748949+00:00.
Case digest / a75cd1da2232cce17671ae597ea62f31a95d096a0f3a5bdb8052eb39522053d9