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.sin(math.pi*(0.5-r))
        else:
            result=math.cos(math.pi*r)
        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=math.sin(math.pi*(0.5-r))
        else:
            result=min(0.0,math.cos(math.pi*r))
        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 the negative branch directly near a half integer.

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


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: return '1'
        if r==1: return '-1'
        if r==0.5: return '0'
        if r<0.5:
            result=math.sin(math.pi*(0.5-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)

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
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%2.0
        if r==0: return '1'
        if r==1: return '-1'
        if r==0.5: return '0'
        if r<0.5:
            result=math.sin(math.pi*(0.5-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 fails to take magnitude after signed reduction.

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


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.sin(math.pi*(0.5-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 '0'
        if r==0.5: return '0'
        if r<0.5:
            result=math.sin(math.pi*(0.5-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 maps odd integers to the even extremum.

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


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 render(math.cos(math.pi*r))
        if r<0.5:
            result=math.sin(math.pi*(0.5-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=math.sin(math.pi*(0.5-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 derives half-integer zero by a rounded cosine.

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


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.sin(math.pi*(0.5-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=math.sin(math.pi*(0.5-r))
        else:
            result=-abs(math.cos(math.pi*r))
        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 omits the negative half-period sign.

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


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: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,math.pi)/math.pi
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi multiplies the unreduced input by pi.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return render(math.tan(math.pi*r))
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return '+infinity'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi treats the finite rounded tangent at a pole as valid.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=1-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi measures pole distance from an integer.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.tan(math.pi*r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(abs(math.tan(math.pi*r)),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi computes the near-pole angle directly.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=1/math.tan(math.pi*d)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,1.0)
        if r==0: return render(math.copysign(0.0,x))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=-1/math.tan(math.pi*d)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi loses the sign of its near-pole branch.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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: return render(abs(r))
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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,1.0)
        if r==0: return "0"
        if abs(r)==0.5: return 'pole'
        if abs(r)>0.25:
            d=0.5-abs(r)
            result=math.copysign(1/math.tan(math.pi*d),r)
        else:
            result=math.tan(math.pi*r)
        return render(result)
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('positive quarter', solve(2.0*N+0.25), "1")
check('negative quarter', solve(-2.0*N-0.25), "-1")
check('pole', solve(N+0.5), "pole")
check('negative pole', solve(-N-0.5), "pole")
check('near positive pole', solve(0.5-N*2.0**-50), render(1/math.tan(math.pi*N*2.0**-50)))
check('near negative pole', solve(-0.5+N*2.0**-50), render(-1/math.tan(math.pi*N*2.0**-50)))
check('beyond pole', solve(0.75), "-1")
check('huge integer', solve(2.0**52+N), "0")
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:
Tangent-pi reports the reduction sign for integer zeros.

Evaluate tan(pi*x) after modulo-one reduction. Exact half integers are poles; integer zeros carry the sign of x. Near poles use a reciprocal tangent of distance to the pole. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.atan(abs(y/x))
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/2
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 divides infinite coordinates before classifying direction.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 ignores the x sign for a doubly infinite direction.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if x<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if x<=0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 identifies the negative real axis using ordinary comparison.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.pi if x<0 else 0.0)
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(-math.pi if x<0 else -0.0)
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 loses the sign of its branch-cut zero.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.pi/2)
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(-math.pi/2)
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 uses a positive angle on the negative vertical axis.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 fails to complement its steep-slope ratio.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(math.copysign(angle,y))
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi+angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 reflects negative x across the wrong axis.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(angle)
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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(y,x):
    try:
        if math.isnan(x) or math.isnan(y): return 'nan'
        if math.isinf(x) and math.isinf(y):
            angle=math.pi/4 if x>0 else 3*math.pi/4
            return render(-angle)
        if y==0:
            return render(math.copysign(math.pi if math.copysign(1.0,x)<0 else 0.0,y))
        if x==0: return render(math.copysign(math.pi/2,y))
        a=abs(x); b=abs(y)
        if b<=a: angle=math.atan(b/a)
        else: angle=math.pi/2-math.atan(a/b)
        if x<0: angle=math.pi-angle
        return render(math.copysign(angle,y))
    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('positive zero axis', solve(0.0,float(N)), "0")
check('negative zero axis', solve(-0.0,float(N)), "-0")
check('branch above', solve(0.0,-float(N)), render(math.pi))
check('branch below', solve(-0.0,-float(N)), render(-math.pi))
check('positive origin', solve(0.0,0.0), "0")
check('positive vertical', solve(float(N),0.0), render(math.pi/2))
check('steep slope', solve(10.0*N,1.0), render(math.atan2(10*N,1)))
check('signed origin', solve(0.0,-0.0), render(math.pi))
check('vertical negative', solve(-float(N),0.0), render(-math.pi/2))
check('quadrant one', solve(float(N),2.0), render(math.atan2(N,2)))
check('quadrant two', solve(float(N),-2.0), render(math.atan2(N,-2)))
check('quadrant three', solve(-float(N),-2.0), render(math.atan2(-N,-2)))
check('tiny slope', solve(N*1e-300,1e300), "0")
check('both infinite', solve(math.inf,math.inf), render(math.pi/4))
check('negative infinite', solve(-math.inf,-math.inf), render(-3*math.pi/4))
check('nan coordinate', solve(float("nan"),float(N)), "nan")
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:
Atan2 discards the lower-half-plane sign.

Evaluate atan2(y,x) including signed zero and infinite directions; NaN produces nan. Finite nonzero coordinates use ratio of smaller magnitude and quadrant reconstruction. 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 decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN

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

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

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

prompt:
Decimal quantization passes source text through a binary float.

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

split: open-access


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

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

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

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

prompt:
Decimal quantization negates the requested quantum exponent.

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

split: open-access


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

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

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

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

prompt:
Decimal quantization discards caller precision.

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

split: open-access


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

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

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

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

prompt:
Decimal quantization substitutes half-up rounding for half-even.

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

split: open-access