FAILURE MAP
← Case archive

FA-17191 / Floating-point arithmetic / Open access

Cube root discards the residual exponent modulo three · case 01

Cube root discards the residual exponent modulo three.

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

ROOT CAUSE

Cube root discards the residual exponent modulo three. The faulty expression is root=m**(1/3).

VERIFIED REPAIR

Apply the contract at this fault site using root=(math.ldexp(m,r))**(1/3).

Unsuccessful approach: The attempted local correction root=(m*r)**(1/3) still violates the explicit regression fixtures.

Case contract

Real cube root on finite binary64 inputs. Split magnitude with frexp, divide exponent by three with floor division, and apply residual exponent before rooting. Return signed zero unchanged. 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 render(x)
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=m**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    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('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube0.793700525981Failed
negative cube-0.79370052598-1Failed
huge7.9370052598e+991e+100Failed
tiny1e-1001e-100Passed
power remainder1.5874010522.5198420998Failed
negative zero-0-0Passed
positive zero00Passed
subnormal1.3518179859e-1081.703183936e-108Failed

SHA-256 / 4c8adb56d13e2e3e290bbc18bb56c0c664a69db1eca3292e697d59f9de37b11c

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)
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=(m*r)**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    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('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube0.793700525981Failed
negative cube-0.79370052598-1Failed
huge7.9370052598e+991e+100Failed
tiny01e-100Failed
power remainder22.5198420998Failed
negative zero-0-0Passed
positive zero00Passed
subnormal1.3518179859e-1081.703183936e-108Failed

SHA-256 / bd0c88dad0e63a7fb288eb559f1e889c5d49101ddde871414d7269118b66d972

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 render(x)
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=(math.ldexp(m,r))**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    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('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube11Passed
negative cube-1-1Passed
huge1e+1001e+100Passed
tiny1e-1001e-100Passed
power remainder2.51984209982.5198420998Passed
negative zero-0-0Passed
positive zero00Passed
subnormal1.703183936e-1081.703183936e-108Passed

SHA-256 / 8d1682424e4547465621b0843c39f37c1b286e588de48c5a99019c32d45b41d1

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

Case digest / aac717082b63457d5bb08048928f0ae146436e89a5b5dc3c96700a05ac7440a8