FAILURE MAP
← Case archive

FA-17201 / Floating-point arithmetic / Open access

Cube root returns the magnitude for negative inputs · case 01

Cube root returns the magnitude for negative inputs.

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

ROOT CAUSE

Cube root returns the magnitude for negative inputs. The faulty expression is return render(result).

THE FAILURE

Cube root returns the magnitude for negative inputs. The faulty expression is return render(result).

Unsuccessful approach: The attempted local correction return render(-result) 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(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('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 cube1-1Failed
huge1e+1001e+100Passed
tiny1e-1001e-100Passed
power remainder2.51984209982.5198420998Passed
negative zero-0-0Passed
positive zero00Passed
subnormal1.703183936e-1081.703183936e-108Passed

SHA-256 / 4807b5c737294edf60453bcf1ab38c04f39b65968fb7075db34aee4ce28a4b5e

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,q)
        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('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 cube-11Failed
negative cube-1-1Passed
huge-1e+1001e+100Failed
tiny-1e-1001e-100Failed
power remainder-2.51984209982.5198420998Failed
negative zero-0-0Passed
positive zero00Passed
subnormal-1.703183936e-1081.703183936e-108Failed

SHA-256 / cd3c703eaca7033ab2f68d7f6b2aba4b963915e3a7d3a71729a559c12ce578bb

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 90a5a7d5432d40ff1844c4e435497cb04ebf8aa32c937d2d9b39c6423257664b