FAILURE MAP
← Case archive

FA-17196 / Floating-point arithmetic / Open access

Cube root rescales by the negated exponent quotient · case 01

Cube root rescales by the negated exponent quotient.

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

ROOT CAUSE

Cube root rescales by the negated exponent quotient. The faulty expression is result=math.ldexp(root,-q).

VERIFIED REPAIR

Apply the contract at this fault site using result=math.ldexp(root,q).

Unsuccessful approach: The attempted local correction result=math.ldexp(root,e) 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=(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
huge1.3064201766e-1001e+100Failed
tiny7.6545051729e+991e-100Failed
power remainder0.629960524952.5198420998Failed
negative zero-0-0Passed
positive zero00Passed
subnormal5.8713564569e+1071.703183936e-108Failed

SHA-256 / 810532c5995f73ecec5a6862138fe0b8eba274bd0473a2170e65966e8b0572f7

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=(math.ldexp(m,r))**(1/3)
        result=math.ldexp(root,e)
        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 cube21Failed
negative cube-2-1Failed
huge1.5309010346e+3001e+100Failed
tiny1.3064201766e-3001e-100Failed
power remainder40.3174735972.5198420998Failed
negative zero-0-0Passed
positive zero00Passed
subnormal9.8813129168e-3241.703183936e-108Failed

SHA-256 / 8bf529dbc9ed60c7aa66e75142b55ff2b6391ffada7c580dcfb98b9d6ebcf76c

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

Case digest / 789a229cd042819d92c79935a070f79ddb8dfae3e547e794607e390391b5abf7