broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [mantissa<<power,1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*mantissa,1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Exact ratio conversion loses sign on integral outputs.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [mantissa,sign*(1<<(-power))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [abs(mantissa),1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Exact ratio conversion assigns sign to the denominator.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw<=rem
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw<=max(rem-1,1)
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding increments at draw equal to remainder.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw<(1<<(k-1))
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=bool(draw&1)
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding replaces the remainder probability with a fair coin.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw<rem
    return [sign*q+int(inc),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw<rem
    return [sign*q-int(inc),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding adds upward in numeric order after sign application.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*(q+int(draw==0)),draw==0]
    inc=draw<rem
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*(q+1),True]
    inc=draw<rem
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding increments an exactly represented input on zero draw.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=draw/(1<<k)<rem//(1<<k)
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>=(1<<k) or draw<0 or draw>=(1<<k): return 'invalid'
    if rem==0: return [sign*q,False]
    inc=round(draw/(1<<k))<round(rem/(1<<k))
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding truncates the probability before sampling.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or rem<0 or rem>(1<<k) or draw<0 or draw>(1<<k): return "invalid"
    if rem==0: return [sign*q,False]
    inc=draw<rem
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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
N = 1
observations = []
def solve(q,rem,k,draw,sign):
    if k<0 or draw<0: return "invalid"
    if rem==0: return [sign*q,False]
    inc=draw<rem
    return [sign*(q+int(inc)),inc]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('draw below', solve(N,3,3,2,1), [N+1,True])
check('draw equality', solve(N,3,3,3,1), [N,False])
check('draw above', solve(N,3,3,7,1), [N,False])
check('negative increment', solve(N,3,3,1,-1), [-N-1,True])
check('negative no increment', solve(N,3,3,5,-1), [-N,False])
check('exact', solve(N,0,3,0,1), [N,False])
check('invalid remainder', solve(N,8,3,0,1), "invalid")
check('invalid draw', solve(N,3,3,8,1), "invalid")
check('large resolution', solve(N,1,54,0,1), [N+1,True])
check('resolution boundary', solve(N,1,54,1,1), [N,False])
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:
Stochastic rounding accepts an out-of-range remainder.

Stipulated stochastic rounding of nonnegative significand with exact dyadic remainder rem/2**k. Draw is uniform integer in [0,2**k); increment magnitude iff draw<rem, then apply sign. Exact results never increment. Return rounded value and whether magnitude incremented.

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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=a+t*(b-a)
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=a+t*min(b-a,1e308)
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation forms an overflowing difference across signs.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=((1-t)*(a+b)+t*(a+b))/2
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=(a+b)/2
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Same-sign interpolation adds endpoints before weighting.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a+0.0)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return "0"
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation computes instead of preserving its first endpoint.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(a+(b-a))
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b+0.0)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation computes instead of preserving its last endpoint.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=t*a+(1-t)*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=t*(a+b)
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation attaches t to the wrong endpoint.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(b,max(a,result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return 'domain'
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=max(a,min(b,result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation clamps a decreasing interval as though increasing.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,t):
    try:
        t=min(1,max(0,t))
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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,t):
    try:
        if not 0<=t<=1: return render(a)
        if t==0: return render(a)
        if t==1: return render(b)
        if (a<=0<=b) or (b<=0<=a):
            result=(1-t)*a+t*b
        else:
            result=a+t*(b-a)
        result=min(max(a,b),max(min(a,b),result))
        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('opposite asymmetric', solve(-float(N),float(N),0.25), render(-N/2))
check('opposite extremes', solve(-1e308,1e308,0.5), "0")
check('same extremes', solve(1e308,1.5e308,0.5), render(1.25e308))
check('first endpoint', solve(-0.0,float(N),0.0), "-0")
check('last endpoint', solve(float(N),-0.0,1.0), "-0")
check('increasing', solve(float(N),float(N+8),0.25), render(N+2))
check('decreasing', solve(float(N+8),float(N),0.25), render(N+6))
check('negative same sign', solve(-float(N+8),-float(N),0.25), render(-N-6))
check('outside', solve(float(N),float(N+8),1.5), "domain")
check('tiny blend', solve(N*1e-300,3*N*1e-300,0.5), render(2*N*1e-300))
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:
Interpolation silently clamps an invalid blend factor.

Interpolate finite a and b at t in [0,1], preserving endpoints and avoiding overflow in a difference or an endpoint sum. Return domain marker outside the interval. 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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=(-b+math.sqrt(d))/(2*a)
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=(-b-math.sqrt(d))/(2*a)
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Quadratic roots compute the small root by subtraction.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+s)
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b-s)
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Quadratic roots choose a fixed square-root sign.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/a
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=q/c
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Complementary quadratic root uses the leading coefficient instead of q.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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,c):
    try:
        if a==0:
            return [render(-c/(2*b))] if b!=0 else ("all" if c==0 else "none")
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(c/b)] if b!=0 else ("all" if c==0 else "none")
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Degenerate quadratic equation applies a quadratic denominator.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/a)]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Repeated quadratic root loses the factor of two.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: d=abs(d)
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: d=0.0
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    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('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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:
Quadratic solver reflects a negative discriminant.

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. 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):
    try:
        r=x
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=math.remainder(math.pi*x,2*math.pi)/math.pi
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi multiplies an unreduced large argument by pi.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=math.remainder(x,1.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=x%1.0
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi reduces by one and loses alternating signs.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return "0"
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,r))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi loses the sign of an exact integer zero.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=r-1
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi fails to reflect the near-integer positive residual.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=1+r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '-1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi reflects a negative residual with positive orientation.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '1'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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):
    try:
        r=math.remainder(x,2.0)
        if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
        if r==0.5: return '1'
        if r==-0.5: return '0'
        if r>0.5: r=1-r
        elif r < -0.5: r=-1-r
        return render(math.sin(math.pi*r))
    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('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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:
Sine-pi assigns the wrong sign to a negative half integer.

Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. 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):
    try:
        r=abs(math.remainder(x,2.0))
        if r==0: return '1'
        if r==1: return '-1'
        if r==0.5: return '0'
        if r<0.5:
            result=math.cos(math.pi*r)
        else:
            result=-math.sin(math.pi*(r-0.5))
        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('even integer', solve(2.0*N), "1")
check('odd integer', solve(2.0*N+1), "-1")
check('negative integer', solve(-2.0*N-1), "-1")
check('half integer', solve(2.0*N+0.5), "0")
check('quarter', solve(0.25), render(math.sqrt(0.5)))
check('three quarters', solve(0.75), render(-math.sqrt(0.5)))
check('near half below', solve(0.5-N*2.0**-50), render(math.sin(math.pi*N*2.0**-50)))
check('near half above', solve(0.5+N*2.0**-50), render(-math.sin(math.pi*N*2.0**-50)))
check('negative half', solve(-0.5), "0")
check('negative quarter', solve(-0.25), render(math.sqrt(0.5)))
check('large integer', solve(2.0**52+2*N), "1")
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):
    try:
        r=abs(math.remainder(x,2.0))
        if r==0: return '1'
        if r==1: return '-1'
        if r==0.5: return '0'
        if r<0.5:
            result=max(0.0,math.cos(math.pi*r))
        else:
            result=-math.sin(math.pi*(r-0.5))
        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('even integer', solve(2.0*N), "1")
check('odd integer', solve(2.0*N+1), "-1")
check('negative integer', solve(-2.0*N-1), "-1")
check('half integer', solve(2.0*N+0.5), "0")
check('quarter', solve(0.25), render(math.sqrt(0.5)))
check('three quarters', solve(0.75), render(-math.sqrt(0.5)))
check('near half below', solve(0.5-N*2.0**-50), render(math.sin(math.pi*N*2.0**-50)))
check('near half above', solve(0.5+N*2.0**-50), render(-math.sin(math.pi*N*2.0**-50)))
check('negative half', solve(-0.5), "0")
check('negative quarter', solve(-0.25), render(math.sqrt(0.5)))
check('large integer', solve(2.0**52+2*N), "1")
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:
Cosine-pi evaluates cosine directly near its exact zero.

Evaluate cos(pi*x) for finite x after modulo-two reduction. Half integers return positive zero; integers are exact; near half integers use a sine of the distance to the half integer. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

split: open-access