FAILURE MAP
← Case archive

FA-346 / Floating-point arithmetic / Open access

A geometric-mean product overflows although the result is finite · case 01

Multiplying observations produces infinity or zero even when their geometric mean is a representable positive number.

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

ROOT CAUSE

The implementation materializes an extreme product before applying the nth root.

VERIFIED REPAIR

Average logarithms with accurate summation and exponentiate once, avoiding the unrepresentable intermediate product.

Unsuccessful approach: Saturating each product at the largest float discards magnitude and does not repair underflow.

Case contract

For a nonempty sequence of finite positive floats, return a logarithm-based geometric mean formatted with ten significant digits. Empty input or any nonpositive observation returns None. Fixtures remain within the representable range of the final mean.

Why this case matters

Multiplicative metrics and ratios can span enormous ranges while their mean stays ordinary. Bounding an intermediate product changes the statistic rather than stabilizing it.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import sys
N = 1
observations = []
def solve(values):
    if not values or any(value <= 0 for value in values):
        return None
    return format(math.prod(values) ** (1 / len(values)), '.10g')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('finite mean despite overflowing product', solve([1e150] * (N + 2)), '1e+150')
check('finite mean despite underflowing product', solve([1e-200] * (N + 1)), '1e-200')
check('balanced reciprocal scales', solve([1e300, 1e-300] * N), '1')
check('ordinary square-root case', solve([4.0, 9.0]), '6')
check('one observation', solve([float(N)]), str(N))
check('unit-valued observations', solve([1.0] * (N + 1)), '1')
check('zero observation rejected', solve([0.0, 1.0]), None)
check('negative observation rejected', solve([-1.0, 2.0]), None)
check('empty sequence', solve([]), None)
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
finite mean despite overflowing productinf1e+150Failed
finite mean despite underflowing product01e-200Failed
balanced reciprocal scales11Passed
ordinary square-root case66Passed
one observation11Passed
unit-valued observations11Passed
zero observation rejectedNoneNonePassed
negative observation rejectedNoneNonePassed
empty sequenceNoneNonePassed

SHA-256 / c4d67fdd217aa723bbcec46fb9b20c91693a426d7cbab5cc7f2040ce37584351

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import sys
N = 1
observations = []
def solve(values):
    if not values or any(value <= 0 for value in values):
        return None
    product = 1.0
    for value in values:
        product = min(product * value, sys.float_info.max)
    return format(product ** (1 / len(values)), '.10g')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('finite mean despite overflowing product', solve([1e150] * (N + 2)), '1e+150')
check('finite mean despite underflowing product', solve([1e-200] * (N + 1)), '1e-200')
check('balanced reciprocal scales', solve([1e300, 1e-300] * N), '1')
check('ordinary square-root case', solve([4.0, 9.0]), '6')
check('one observation', solve([float(N)]), str(N))
check('unit-valued observations', solve([1.0] * (N + 1)), '1')
check('zero observation rejected', solve([0.0, 1.0]), None)
check('negative observation rejected', solve([-1.0, 2.0]), None)
check('empty sequence', solve([]), None)
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
finite mean despite overflowing product5.643803094e+1021e+150Failed
finite mean despite underflowing product01e-200Failed
balanced reciprocal scales11Passed
ordinary square-root case66Passed
one observation11Passed
unit-valued observations11Passed
zero observation rejectedNoneNonePassed
negative observation rejectedNoneNonePassed
empty sequenceNoneNonePassed

SHA-256 / bd6be5f6346a2ab28039ce564d4dc8b237e4f688ae0bb9fe1e74275c6de6989f

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import sys
N = 1
observations = []
def solve(values):
    if not values or any(value <= 0 for value in values):
        return None
    mean_log = math.fsum(math.log(value) for value in values) / len(values)
    return format(math.exp(mean_log), '.10g')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('finite mean despite overflowing product', solve([1e150] * (N + 2)), '1e+150')
check('finite mean despite underflowing product', solve([1e-200] * (N + 1)), '1e-200')
check('balanced reciprocal scales', solve([1e300, 1e-300] * N), '1')
check('ordinary square-root case', solve([4.0, 9.0]), '6')
check('one observation', solve([float(N)]), str(N))
check('unit-valued observations', solve([1.0] * (N + 1)), '1')
check('zero observation rejected', solve([0.0, 1.0]), None)
check('negative observation rejected', solve([-1.0, 2.0]), None)
check('empty sequence', solve([]), None)
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
finite mean despite overflowing product1e+1501e+150Passed
finite mean despite underflowing product1e-2001e-200Passed
balanced reciprocal scales11Passed
ordinary square-root case66Passed
one observation11Passed
unit-valued observations11Passed
zero observation rejectedNoneNonePassed
negative observation rejectedNoneNonePassed
empty sequenceNoneNonePassed

SHA-256 / 2acc28c9f45f1b5279b9a6852aa70ad62b40789e6f8a4627c7c5f012f3b4bd68

Verification & scope

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

Case digest / c01b36d90aa6f56fd6d12d0a005abb2c3f020135405ba60bcf6bc34138f789c1