broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-99,Emax=99)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization ignores the specified exponent range.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result.normalize()),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result.normalize()) if result.is_finite() else str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization strips zeros required by the requested quantum.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(abs(result)) if result.is_zero() else str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result.copy_abs()),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization loses the sign of a rounded zero.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised and (signal is not decimal.Rounded or ctx.flags[decimal.Inexact]))
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised and signal is not decimal.Rounded)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization drops Rounded unless the value was inexact.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted("Underflow" if signal is decimal.Subnormal else signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=ctx.quantize(value,quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised and signal is not decimal.Subnormal)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization mistakes an exact subnormal for underflow.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=value.quantize(quantum)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(text, exponent, precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)
    for signal in ctx.traps: ctx.traps[signal]=False
    ctx.clear_flags()
    value=Decimal(text)
    quantum=Decimal((0,(1,),exponent))
    result=value.quantize(quantum,rounding=ROUND_HALF_EVEN)
    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)
    return [str(result),flags]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie odd', solve(str(N)+".255",-2,6), [str(N)+".26",["Inexact","Rounded"]])
check('tie even', solve(str(N)+".245",-2,6), [str(N)+".24",["Inexact","Rounded"]])
check('rounded exact', solve(str(N)+".200",-2,6), [str(N)+".20",["Rounded"]])
check('already exact', solve(str(N)+".20",-2,6), [str(N)+".20",[]])
check('one excess digit', solve("123.45",-2,4), ["NaN",["InvalidOperation"]])
check('coefficient too large', solve("12345.67",-2,4), ["NaN",["InvalidOperation"]])
check('subnormal exact', solve("1e-10",-10,6), ["1E-10",["Subnormal"]])
check('negative zero', solve("-0.004",-2,6), ["-0.00",["Inexact","Rounded"]])
check('positive zero', solve("0.004",-2,6), ["0.00",["Inexact","Rounded"]])
check('integer quantum', solve("123.4",1,6), ["1.2E+2",["Inexact","Rounded"]])
check('overflow exponent', solve("1e10",0,6), ["NaN",["InvalidOperation"]])
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)

prompt:
Decimal quantization creates a context but uses the ambient one.

Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.add(ctx.multiply(av,bv),cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.add(ctx.multiply(av,bv),ctx.plus(cv))
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add rounds the product before cancellation.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=ctx.create_decimal(a); bv=ctx.create_decimal(b); cv=ctx.create_decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=ctx.create_decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add rounds inputs to working precision.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=av.fma(bv,cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=av*bv+cv
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add forgets its local context.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,-cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,abs(cv))
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add applies the wrong addend sign.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_UP)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_DOWN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add uses away ties in an even context.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),False]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

N = 1
observations = []
def solve(a,b,c,precision):
    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
    for signal in ctx.traps: ctx.traps[signal]=False
    av=Decimal(a); bv=Decimal(b); cv=Decimal(c)
    result=ctx.fma(av,bv,cv)
    return [str(result),ctx.flags[decimal.Rounded] and not ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
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)

prompt:
Decimal fused multiply-add reports rounded zeros as exact.

Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.

split: open-access


broken_source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=y*math.log(1+x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=y*math.log(max(1+x,1e-300))
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

prompt:
Power of one plus a small increment rounds the base before amplification.

Evaluate (1+x)**y without first rounding a small increment into unity. Domain requires x>-1; y is finite, and fixtures have finite results. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=math.log1p(y*x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=math.log1p(x)/y
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

prompt:
Power increment moves the exponent inside log1p.

Evaluate (1+x)**y without first rounding a small increment into unity. Domain requires x>-1; y is finite, and fixtures have finite results. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=abs(y)*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '1'
        exponent=-y*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

prompt:
Power increment drops the sign of its exponent.

Evaluate (1+x)**y without first rounding a small increment into unity. Domain requires x>-1; y is finite, and fixtures have finite results. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return '0'
        exponent=y*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

source:
"""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,y):
    try:
        if x<=-1: return 'domain'
        if y==0 or x==0: return render(y)
        exponent=y*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

prompt:
Power increment uses zero as its multiplicative identity.

Evaluate (1+x)**y without first rounding a small increment into unity. Domain requires x>-1; y is finite, and fixtures have finite results. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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,y):
    try:
        if x<=-1: x=abs(x)
        if y==0 or x==0: return '1'
        exponent=y*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

source:
"""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,y):
    try:
        if x<=-1: return 'nan'
        if y==0 or x==0: return '1'
        exponent=y*math.log1p(x)
        result=math.exp(exponent)
        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('tiny amplified', solve(N*2.0**-60,2.0**60), render(math.exp(N)))
check('negative amplified', solve(-N*2.0**-60,2.0**60), render(math.exp(-N)))
check('normal', solve(1.0,float(N)), render(2.0**N))
check('negative power', solve(1.0,-float(N)), render(2.0**(-N)))
check('zero exponent', solve(0.5,0.0), "1")
check('zero increment', solve(0.0,float(N)), "1")
check('invalid base', solve(-2.0,float(N)), "domain")
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)

prompt:
Power increment reflects an invalid base into the real domain.

Evaluate (1+x)**y without first rounding a small increment into unity. Domain requires x>-1; y is finite, and fixtures have finite results. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a==b: return "0"
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

source:
"""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(a,b):
    try:
        if a==b: return "1"
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

prompt:
Exponential divided difference sets its coincident limit to zero.

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=(math.exp(b)-math.exp(a))/(d*math.exp(a))
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=(math.exp(d)-1)/d
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

prompt:
Exponential divided difference subtracts close endpoint exponentials.

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(b)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

prompt:
Exponential divided difference applies its factor at the wrong endpoint.

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/abs(d)
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=abs(math.expm1(d))/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

prompt:
Exponential divided difference divides by an unsigned separation.

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=a-b
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

source:
"""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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=abs(b-a)
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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)

prompt:
Exponential divided difference reverses its exponent separation.

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=(math.log(b)-math.log(a))/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=math.log(b/a)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

prompt:
Log divided difference subtracts logarithms of adjacent large values.

Evaluate (log(b)-log(a))/(b-a) for positive finite endpoints with continuous limit 1/a. Close ratios use log1p; fixtures have finite outputs. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(math.log(a))
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return "0"
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

prompt:
Log divided difference uses the logarithm as its coincident limit.

Evaluate (log(b)-log(a))/(b-a) for positive finite endpoints with continuous limit 1/a. Close ratios use log1p; fixtures have finite outputs. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/b
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/max(a,b)
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

prompt:
Log divided difference normalizes its increment by the destination.

Evaluate (log(b)-log(a))/(b-a) for positive finite endpoints with continuous limit 1/a. Close ratios use log1p; fixtures have finite outputs. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=math.log1p(r)/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=b-a
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=math.log(max(b/a,1e-300))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

prompt:
Log divided difference uses log1p even when the normalized decrement rounds to minus one.

Evaluate (log(b)-log(a))/(b-a) for positive finite endpoints with continuous limit 1/a. Close ratios use log1p; fixtures have finite outputs. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=abs(b-a)
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return render(1/a)
        d=a-b
        r=d/a
        if abs(r)<0.5:
            result=math.log1p(r)/d
        else:
            result=(math.log(b)-math.log(a))/d
        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('coincident', solve(float(N),float(N)), render(1/N))
check('close', solve(1.0,1.0+N*2.0**-50), render(math.log1p(N*2.0**-50)/(N*2.0**-50)))
check('moderate close', solve(1.0,1.125), render(math.log(1.125)/0.125))
check('far reverse', solve(1e300,1e-300), render((math.log(1e-300)-math.log(1e300))/(1e-300-1e300)))
check('close large', solve(1e100,math.nextafter(1e100,math.inf)), render(1e-100))
check('forward', solve(1.0,float(N+1)), render(math.log(N+1)/N))
check('reverse', solve(float(N+1),1.0), render(math.log(N+1)/N))
check('far', solve(1e-100,1e100), render((200*math.log(10))/(1e100-1e-100)))
check('zero', solve(0.0,float(N)), "domain")
check('negative', solve(float(N),-1.0), "domain")
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)

prompt:
Log divided difference drops the sign of its denominator.

Evaluate (log(b)-log(a))/(b-a) for positive finite endpoints with continuous limit 1/a. Close ratios use log1p; fixtures have finite outputs. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access


broken_source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return '0'
        r=(a-b)/b
        if abs(r)<0.5:
            result=math.log1p(r)
        else:
            result=math.log(a/b)
        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('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))
check('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))
check('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))
check('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))
check('normal', solve(float(N+1),1.0), render(math.log(N+1)))
check('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))
check('equal', solve(float(N),float(N)), "0")
check('invalid', solve(0.0,float(N)), "domain")
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)

source:
"""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(a,b):
    try:
        if a<=0 or b<=0: return 'domain'
        if a==b: return '0'
        r=(a-b)/b
        if abs(r)<0.5:
            result=math.log1p(r)
        else:
            result=math.log(max(min(a/b,1e300),1e-300))
        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('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))
check('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))
check('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))
check('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))
check('normal', solve(float(N+1),1.0), render(math.log(N+1)))
check('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))
check('equal', solve(float(N),float(N)), "0")
check('invalid', solve(0.0,float(N)), "domain")
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)

prompt:
Log ratio materializes an overflowing or underflowing quotient.

Evaluate log(a/b) for positive finite endpoints without overflowing an intermediate quotient and without cancellation for nearby operands. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access