{"abstract":"Scaled square root clamps a negative operand to zero.","category":"Floating-point arithmetic","checks":9,"contract":"Nonnegative square root of finite binary64 x via exponent normalization. Negative input returns domain; negative zero is preserved. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.","evaluation_group":"s3-float-sqrt-scaled","failed_approach":"The attempted local correction if x<0: x=abs(x) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-sqrt-scaled-negative-clamp","id":"FA-17221","implementations":{"attempt":{"sha256":"33755f8b821ca7be3c330defa157dd8f06c240335425aaa4443f80fc59c00adf","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport struct\ndef render(x):\n    if math.isnan(x): return 'nan'\n    if math.isinf(x): return '-infinity' if x<0 else '+infinity'\n    return format(x,'.11g')\n\nN = 1\nobservations = []\ndef solve(x):\n    try:\n        if x<0: x=abs(x)\n        if x==0: return render(x)\n        m,e=math.frexp(x)\n        q,r=divmod(e,2)\n        root=math.sqrt(math.ldexp(m,r))\n        return render(math.ldexp(root,q))\n    except (ValueError, OverflowError, ZeroDivisionError, TypeError):\n        return \"arithmetic-error\"\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('square', solve(float(N*N)), render(float(N)))\ncheck('normal', solve(float(N)), render(math.sqrt(N)))\ncheck('huge', solve(1e300), \"1e+150\")\ncheck('tiny', solve(1e-300), \"1e-150\")\ncheck('odd exponent', solve(2.0), render(math.sqrt(2)))\ncheck('positive root zero', solve(0.0), \"0\")\ncheck('negative domain', solve(-float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-0\")\ncheck('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-537)))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"88e32b29505ac97e30114d6352852739f4a66e526b02dc5570de4d38809582bd","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport struct\ndef render(x):\n    if math.isnan(x): return 'nan'\n    if math.isinf(x): return '-infinity' if x<0 else '+infinity'\n    return format(x,'.11g')\n\nN = 1\nobservations = []\ndef solve(x):\n    try:\n        if x<0: return '0'\n        if x==0: return render(x)\n        m,e=math.frexp(x)\n        q,r=divmod(e,2)\n        root=math.sqrt(math.ldexp(m,r))\n        return render(math.ldexp(root,q))\n    except (ValueError, OverflowError, ZeroDivisionError, TypeError):\n        return \"arithmetic-error\"\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('square', solve(float(N*N)), render(float(N)))\ncheck('normal', solve(float(N)), render(math.sqrt(N)))\ncheck('huge', solve(1e300), \"1e+150\")\ncheck('tiny', solve(1e-300), \"1e-150\")\ncheck('odd exponent', solve(2.0), render(math.sqrt(2)))\ncheck('positive root zero', solve(0.0), \"0\")\ncheck('negative domain', solve(-float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-0\")\ncheck('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-537)))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"a2be440e40877a8ca6d5cbe5e4d7abbf5c9581a86035cddc86c6c1bf1b225c3e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport struct\ndef render(x):\n    if math.isnan(x): return 'nan'\n    if math.isinf(x): return '-infinity' if x<0 else '+infinity'\n    return format(x,'.11g')\n\nN = 1\nobservations = []\ndef solve(x):\n    try:\n        if x<0: return 'domain'\n        if x==0: return render(x)\n        m,e=math.frexp(x)\n        q,r=divmod(e,2)\n        root=math.sqrt(math.ldexp(m,r))\n        return render(math.ldexp(root,q))\n    except (ValueError, OverflowError, ZeroDivisionError, TypeError):\n        return \"arithmetic-error\"\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('square', solve(float(N*N)), render(float(N)))\ncheck('normal', solve(float(N)), render(math.sqrt(N)))\ncheck('huge', solve(1e300), \"1e+150\")\ncheck('tiny', solve(1e-300), \"1e-150\")\ncheck('odd exponent', solve(2.0), render(math.sqrt(2)))\ncheck('positive root zero', solve(0.0), \"0\")\ncheck('negative domain', solve(-float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-0\")\ncheck('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-537)))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"s3-floating_point_arithmetic-sqrt-scaled-negative-clamp","generated_at":"2026-09-29T14:39:44.233745+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"An offline floating representation model isolates a reproducible arithmetic fault.","repair":"Apply the contract at this fault site using if x<0: return 'domain'.","root_cause":"Scaled square root clamps a negative operand to zero. The faulty expression is if x<0: return '0'.","sha256":"68288e084bc9bbf481d7fa441d08ad368340bd1477eac03030d0d0511fc4e2c1","title":"Scaled square root clamps a negative operand to zero · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.719,"exit_code":1,"observations":[{"actual":"1","check":"square","expected":"1","passed":true},{"actual":"1","check":"normal","expected":"1","passed":true},{"actual":"1e+150","check":"huge","expected":"1e+150","passed":true},{"actual":"1e-150","check":"tiny","expected":"1e-150","passed":true},{"actual":"1.4142135624","check":"odd exponent","expected":"1.4142135624","passed":true},{"actual":"0","check":"positive root zero","expected":"0","passed":true},{"actual":"1","check":"negative domain","expected":"domain","passed":false},{"actual":"-0","check":"negative zero","expected":"-0","passed":true},{"actual":"2.2227587495e-162","check":"subnormal","expected":"2.2227587495e-162","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"square\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"huge\", \"actual\": \"1e+150\", \"expected\": \"1e+150\", \"passed\": true}, {\"check\": \"tiny\", \"actual\": \"1e-150\", \"expected\": \"1e-150\", \"passed\": true}, {\"check\": \"odd exponent\", \"actual\": \"1.4142135624\", \"expected\": \"1.4142135624\", \"passed\": true}, {\"check\": \"positive root zero\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"negative domain\", \"actual\": \"1\", \"expected\": \"domain\", \"passed\": false}, {\"check\": \"negative zero\", \"actual\": \"-0\", \"expected\": \"-0\", \"passed\": true}, {\"check\": \"subnormal\", \"actual\": \"2.2227587495e-162\", \"expected\": \"2.2227587495e-162\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.422,"exit_code":1,"observations":[{"actual":"1","check":"square","expected":"1","passed":true},{"actual":"1","check":"normal","expected":"1","passed":true},{"actual":"1e+150","check":"huge","expected":"1e+150","passed":true},{"actual":"1e-150","check":"tiny","expected":"1e-150","passed":true},{"actual":"1.4142135624","check":"odd exponent","expected":"1.4142135624","passed":true},{"actual":"0","check":"positive root zero","expected":"0","passed":true},{"actual":"0","check":"negative domain","expected":"domain","passed":false},{"actual":"-0","check":"negative zero","expected":"-0","passed":true},{"actual":"2.2227587495e-162","check":"subnormal","expected":"2.2227587495e-162","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"square\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"huge\", \"actual\": \"1e+150\", \"expected\": \"1e+150\", \"passed\": true}, {\"check\": \"tiny\", \"actual\": \"1e-150\", \"expected\": \"1e-150\", \"passed\": true}, {\"check\": \"odd exponent\", \"actual\": \"1.4142135624\", \"expected\": \"1.4142135624\", \"passed\": true}, {\"check\": \"positive root zero\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"negative domain\", \"actual\": \"0\", \"expected\": \"domain\", \"passed\": false}, {\"check\": \"negative zero\", \"actual\": \"-0\", \"expected\": \"-0\", \"passed\": true}, {\"check\": \"subnormal\", \"actual\": \"2.2227587495e-162\", \"expected\": \"2.2227587495e-162\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.786,"exit_code":0,"observations":[{"actual":"1","check":"square","expected":"1","passed":true},{"actual":"1","check":"normal","expected":"1","passed":true},{"actual":"1e+150","check":"huge","expected":"1e+150","passed":true},{"actual":"1e-150","check":"tiny","expected":"1e-150","passed":true},{"actual":"1.4142135624","check":"odd exponent","expected":"1.4142135624","passed":true},{"actual":"0","check":"positive root zero","expected":"0","passed":true},{"actual":"domain","check":"negative domain","expected":"domain","passed":true},{"actual":"-0","check":"negative zero","expected":"-0","passed":true},{"actual":"2.2227587495e-162","check":"subnormal","expected":"2.2227587495e-162","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"square\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"huge\", \"actual\": \"1e+150\", \"expected\": \"1e+150\", \"passed\": true}, {\"check\": \"tiny\", \"actual\": \"1e-150\", \"expected\": \"1e-150\", \"passed\": true}, {\"check\": \"odd exponent\", \"actual\": \"1.4142135624\", \"expected\": \"1.4142135624\", \"passed\": true}, {\"check\": \"positive root zero\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"negative domain\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}, {\"check\": \"negative zero\", \"actual\": \"-0\", \"expected\": \"-0\", \"passed\": true}, {\"check\": \"subnormal\", \"actual\": \"2.2227587495e-162\", \"expected\": \"2.2227587495e-162\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}