{"abstract":"Positive-real square root subtracts nearly equal radii.","category":"Floating-point arithmetic","checks":10,"contract":"Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.","evaluation_group":"s3-float-complex-sqrt","failed_approach":"The attempted local correction imag=math.copysign(math.sqrt(max(0,(r-x)/2)),y) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-complex-sqrt-imag-cancellation","id":"FA-16446","implementations":{"attempt":{"sha256":"d02f5ee265ed7002b1a7f652b5a550c4f99919021ea401356a9f8ccc36948921","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,y):\n    try:\n        if x==0 and y==0: return ['0',render(y)]\n        r=math.hypot(x,y)\n        t=math.sqrt(r/2+abs(x)/2)\n        if x>=0:\n            real=t\n            imag=math.copysign(math.sqrt(max(0,(r-x)/2)),y)\n        else:\n            imag=math.copysign(t,y)\n            real=abs(y)/(2*t)\n        return [render(real),render(imag)]\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('positive axis', solve(float(N*N),0.0), [render(float(N)),\"0\"])\ncheck('negative axis above', solve(-float(N*N),0.0), [\"0\",render(float(N))])\ncheck('negative axis below', solve(-float(N*N),-0.0), [\"0\",render(-float(N))])\ncheck('upper quadrant', solve(3.0,4.0), [\"2\",\"1\"])\ncheck('lower quadrant', solve(3.0,-4.0), [\"2\",\"-1\"])\ncheck('negative real quadrant', solve(-3.0,4.0), [\"1\",\"2\"])\ncheck('huge axis', solve(1e308,0.0), [\"1e+154\",\"0\"])\ncheck('tiny imaginary', solve(4.0,N*1e-200), [\"2\",render(N*1e-200/4)])\ncheck('origin above', solve(0.0,0.0), [\"0\",\"0\"])\ncheck('origin below', solve(0.0,-0.0), [\"0\",\"-0\"])\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":"7a87c80628adc3e80eeb10c45b8981412d40b342b82e72dc3cff38a1652122a9","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,y):\n    try:\n        if x==0 and y==0: return ['0',render(y)]\n        r=math.hypot(x,y)\n        t=math.sqrt(r/2+abs(x)/2)\n        if x>=0:\n            real=t\n            imag=math.copysign(math.sqrt((r-x)/2),y)\n        else:\n            imag=math.copysign(t,y)\n            real=abs(y)/(2*t)\n        return [render(real),render(imag)]\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('positive axis', solve(float(N*N),0.0), [render(float(N)),\"0\"])\ncheck('negative axis above', solve(-float(N*N),0.0), [\"0\",render(float(N))])\ncheck('negative axis below', solve(-float(N*N),-0.0), [\"0\",render(-float(N))])\ncheck('upper quadrant', solve(3.0,4.0), [\"2\",\"1\"])\ncheck('lower quadrant', solve(3.0,-4.0), [\"2\",\"-1\"])\ncheck('negative real quadrant', solve(-3.0,4.0), [\"1\",\"2\"])\ncheck('huge axis', solve(1e308,0.0), [\"1e+154\",\"0\"])\ncheck('tiny imaginary', solve(4.0,N*1e-200), [\"2\",render(N*1e-200/4)])\ncheck('origin above', solve(0.0,0.0), [\"0\",\"0\"])\ncheck('origin below', solve(0.0,-0.0), [\"0\",\"-0\"])\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":"9a44494b75975666e33f4c600a76b1f2e736a5bb390106b9c4809fc638a9569d","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,y):\n    try:\n        if x==0 and y==0: return ['0',render(y)]\n        r=math.hypot(x,y)\n        t=math.sqrt(r/2+abs(x)/2)\n        if x>=0:\n            real=t\n            imag=y/(2*t)\n        else:\n            imag=math.copysign(t,y)\n            real=abs(y)/(2*t)\n        return [render(real),render(imag)]\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('positive axis', solve(float(N*N),0.0), [render(float(N)),\"0\"])\ncheck('negative axis above', solve(-float(N*N),0.0), [\"0\",render(float(N))])\ncheck('negative axis below', solve(-float(N*N),-0.0), [\"0\",render(-float(N))])\ncheck('upper quadrant', solve(3.0,4.0), [\"2\",\"1\"])\ncheck('lower quadrant', solve(3.0,-4.0), [\"2\",\"-1\"])\ncheck('negative real quadrant', solve(-3.0,4.0), [\"1\",\"2\"])\ncheck('huge axis', solve(1e308,0.0), [\"1e+154\",\"0\"])\ncheck('tiny imaginary', solve(4.0,N*1e-200), [\"2\",render(N*1e-200/4)])\ncheck('origin above', solve(0.0,0.0), [\"0\",\"0\"])\ncheck('origin below', solve(0.0,-0.0), [\"0\",\"-0\"])\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-complex-sqrt-imag-cancellation","generated_at":"2026-09-29T14:39:36.377226+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 imag=y/(2*t).","root_cause":"Positive-real square root subtracts nearly equal radii. The faulty expression is imag=math.copysign(math.sqrt((r-x)/2),y).","sha256":"579489d3631f1b5d8149763798a2083e98751f1b65556b5ca2d0f6aa37858d11","title":"Positive-real square root subtracts nearly equal radii · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":43.046,"exit_code":1,"observations":[{"actual":["1","0"],"check":"positive axis","expected":["1","0"],"passed":true},{"actual":["0","1"],"check":"negative axis above","expected":["0","1"],"passed":true},{"actual":["0","-1"],"check":"negative axis below","expected":["0","-1"],"passed":true},{"actual":["2","1"],"check":"upper quadrant","expected":["2","1"],"passed":true},{"actual":["2","-1"],"check":"lower quadrant","expected":["2","-1"],"passed":true},{"actual":["1","2"],"check":"negative real quadrant","expected":["1","2"],"passed":true},{"actual":["1e+154","0"],"check":"huge axis","expected":["1e+154","0"],"passed":true},{"actual":["2","0"],"check":"tiny imaginary","expected":["2","2.5e-201"],"passed":false},{"actual":["0","0"],"check":"origin above","expected":["0","0"],"passed":true},{"actual":["0","-0"],"check":"origin below","expected":["0","-0"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"positive axis\", \"actual\": [\"1\", \"0\"], \"expected\": [\"1\", \"0\"], \"passed\": true}, {\"check\": \"negative axis above\", \"actual\": [\"0\", \"1\"], \"expected\": [\"0\", \"1\"], \"passed\": true}, {\"check\": \"negative axis below\", \"actual\": [\"0\", \"-1\"], \"expected\": [\"0\", \"-1\"], \"passed\": true}, {\"check\": \"upper quadrant\", \"actual\": [\"2\", \"1\"], \"expected\": [\"2\", \"1\"], \"passed\": true}, {\"check\": \"lower quadrant\", \"actual\": [\"2\", \"-1\"], \"expected\": [\"2\", \"-1\"], \"passed\": true}, {\"check\": \"negative real quadrant\", \"actual\": [\"1\", \"2\"], \"expected\": [\"1\", \"2\"], \"passed\": true}, {\"check\": \"huge axis\", \"actual\": [\"1e+154\", \"0\"], \"expected\": [\"1e+154\", \"0\"], \"passed\": true}, {\"check\": \"tiny imaginary\", \"actual\": [\"2\", \"0\"], \"expected\": [\"2\", \"2.5e-201\"], \"passed\": false}, {\"check\": \"origin above\", \"actual\": [\"0\", \"0\"], \"expected\": [\"0\", \"0\"], \"passed\": true}, {\"check\": \"origin below\", \"actual\": [\"0\", \"-0\"], \"expected\": [\"0\", \"-0\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.468,"exit_code":1,"observations":[{"actual":["1","0"],"check":"positive axis","expected":["1","0"],"passed":true},{"actual":["0","1"],"check":"negative axis above","expected":["0","1"],"passed":true},{"actual":["0","-1"],"check":"negative axis below","expected":["0","-1"],"passed":true},{"actual":["2","1"],"check":"upper quadrant","expected":["2","1"],"passed":true},{"actual":["2","-1"],"check":"lower quadrant","expected":["2","-1"],"passed":true},{"actual":["1","2"],"check":"negative real quadrant","expected":["1","2"],"passed":true},{"actual":["1e+154","0"],"check":"huge axis","expected":["1e+154","0"],"passed":true},{"actual":["2","0"],"check":"tiny imaginary","expected":["2","2.5e-201"],"passed":false},{"actual":["0","0"],"check":"origin above","expected":["0","0"],"passed":true},{"actual":["0","-0"],"check":"origin below","expected":["0","-0"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"positive axis\", \"actual\": [\"1\", \"0\"], \"expected\": [\"1\", \"0\"], \"passed\": true}, {\"check\": \"negative axis above\", \"actual\": [\"0\", \"1\"], \"expected\": [\"0\", \"1\"], \"passed\": true}, {\"check\": \"negative axis below\", \"actual\": [\"0\", \"-1\"], \"expected\": [\"0\", \"-1\"], \"passed\": true}, {\"check\": \"upper quadrant\", \"actual\": [\"2\", \"1\"], \"expected\": [\"2\", \"1\"], \"passed\": true}, {\"check\": \"lower quadrant\", \"actual\": [\"2\", \"-1\"], \"expected\": [\"2\", \"-1\"], \"passed\": true}, {\"check\": \"negative real quadrant\", \"actual\": [\"1\", \"2\"], \"expected\": [\"1\", \"2\"], \"passed\": true}, {\"check\": \"huge axis\", \"actual\": [\"1e+154\", \"0\"], \"expected\": [\"1e+154\", \"0\"], \"passed\": true}, {\"check\": \"tiny imaginary\", \"actual\": [\"2\", \"0\"], \"expected\": [\"2\", \"2.5e-201\"], \"passed\": false}, {\"check\": \"origin above\", \"actual\": [\"0\", \"0\"], \"expected\": [\"0\", \"0\"], \"passed\": true}, {\"check\": \"origin below\", \"actual\": [\"0\", \"-0\"], \"expected\": [\"0\", \"-0\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.423,"exit_code":0,"observations":[{"actual":["1","0"],"check":"positive axis","expected":["1","0"],"passed":true},{"actual":["0","1"],"check":"negative axis above","expected":["0","1"],"passed":true},{"actual":["0","-1"],"check":"negative axis below","expected":["0","-1"],"passed":true},{"actual":["2","1"],"check":"upper quadrant","expected":["2","1"],"passed":true},{"actual":["2","-1"],"check":"lower quadrant","expected":["2","-1"],"passed":true},{"actual":["1","2"],"check":"negative real quadrant","expected":["1","2"],"passed":true},{"actual":["1e+154","0"],"check":"huge axis","expected":["1e+154","0"],"passed":true},{"actual":["2","2.5e-201"],"check":"tiny imaginary","expected":["2","2.5e-201"],"passed":true},{"actual":["0","0"],"check":"origin above","expected":["0","0"],"passed":true},{"actual":["0","-0"],"check":"origin below","expected":["0","-0"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"positive axis\", \"actual\": [\"1\", \"0\"], \"expected\": [\"1\", \"0\"], \"passed\": true}, {\"check\": \"negative axis above\", \"actual\": [\"0\", \"1\"], \"expected\": [\"0\", \"1\"], \"passed\": true}, {\"check\": \"negative axis below\", \"actual\": [\"0\", \"-1\"], \"expected\": [\"0\", \"-1\"], \"passed\": true}, {\"check\": \"upper quadrant\", \"actual\": [\"2\", \"1\"], \"expected\": [\"2\", \"1\"], \"passed\": true}, {\"check\": \"lower quadrant\", \"actual\": [\"2\", \"-1\"], \"expected\": [\"2\", \"-1\"], \"passed\": true}, {\"check\": \"negative real quadrant\", \"actual\": [\"1\", \"2\"], \"expected\": [\"1\", \"2\"], \"passed\": true}, {\"check\": \"huge axis\", \"actual\": [\"1e+154\", \"0\"], \"expected\": [\"1e+154\", \"0\"], \"passed\": true}, {\"check\": \"tiny imaginary\", \"actual\": [\"2\", \"2.5e-201\"], \"expected\": [\"2\", \"2.5e-201\"], \"passed\": true}, {\"check\": \"origin above\", \"actual\": [\"0\", \"0\"], \"expected\": [\"0\", \"0\"], \"passed\": true}, {\"check\": \"origin below\", \"actual\": [\"0\", \"-0\"], \"expected\": [\"0\", \"-0\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}