{"abstract":"Complementary log exponentials subtract near unity.","category":"Floating-point arithmetic","checks":7,"contract":"Evaluate log(1-exp(x)) for x <= 0; zero maps to negative infinity. Choose a cancellation-safe formula on either side of -log(2). Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.","evaluation_group":"s3-float-log1mexp","failed_approach":"The attempted local correction result=math.log(max(1-math.exp(x),1e-300)) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-log1mexp-near-cancellation","id":"FA-16131","implementations":{"attempt":{"sha256":"8fe424071b269c55338348a4068d8b9aab49e72b0500330230bcf74911d09026","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 '-infinity'\n        if x < -math.log(2):\n            result=math.log1p(-math.exp(x))\n        else:\n            result=math.log(max(1-math.exp(x),1e-300))\n        return render(result)\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('near zero', solve(-N*2.0**-60), render(math.log(N*2.0**-60)))\ncheck('far tail', solve(-50.0-N), render(-math.exp(-50.0-N)))\ncheck('midpoint', solve(-math.log(2)), render(math.log(0.5)))\ncheck('moderate', solve(-1.0), render(math.log1p(-math.exp(-1))))\ncheck('boundary', solve(0.0), \"-infinity\")\ncheck('invalid', solve(float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-infinity\")\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":"a89acd20866d09f18263cf6109b19df77d4b72ff9078fe7156f6675c1bafda78","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 '-infinity'\n        if x < -math.log(2):\n            result=math.log1p(-math.exp(x))\n        else:\n            result=math.log(1-math.exp(x))\n        return render(result)\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('near zero', solve(-N*2.0**-60), render(math.log(N*2.0**-60)))\ncheck('far tail', solve(-50.0-N), render(-math.exp(-50.0-N)))\ncheck('midpoint', solve(-math.log(2)), render(math.log(0.5)))\ncheck('moderate', solve(-1.0), render(math.log1p(-math.exp(-1))))\ncheck('boundary', solve(0.0), \"-infinity\")\ncheck('invalid', solve(float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-infinity\")\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":"9e8c3385fce009a483a0721ec097c0bbf8027e9adedc27f92b435b5d6d83082d","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 '-infinity'\n        if x < -math.log(2):\n            result=math.log1p(-math.exp(x))\n        else:\n            result=math.log(-math.expm1(x))\n        return render(result)\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('near zero', solve(-N*2.0**-60), render(math.log(N*2.0**-60)))\ncheck('far tail', solve(-50.0-N), render(-math.exp(-50.0-N)))\ncheck('midpoint', solve(-math.log(2)), render(math.log(0.5)))\ncheck('moderate', solve(-1.0), render(math.log1p(-math.exp(-1))))\ncheck('boundary', solve(0.0), \"-infinity\")\ncheck('invalid', solve(float(N)), \"domain\")\ncheck('negative zero', solve(-0.0), \"-infinity\")\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-log1mexp-near-cancellation","generated_at":"2026-09-29T14:39:33.389995+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 result=math.log(-math.expm1(x)).","root_cause":"Complementary log exponentials subtract near unity. The faulty expression is result=math.log(1-math.exp(x)).","sha256":"bc562a0346400af46bc8a9b5b6127549ea7c69bac0a7bcf9f2a68822fee813aa","title":"Complementary log exponentials subtract near unity · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.577,"exit_code":1,"observations":[{"actual":"-690.7755279","check":"near zero","expected":"-41.588830834","passed":false},{"actual":"-7.0954741623e-23","check":"far tail","expected":"-7.0954741623e-23","passed":true},{"actual":"-0.69314718056","check":"midpoint","expected":"-0.69314718056","passed":true},{"actual":"-0.45867514539","check":"moderate","expected":"-0.45867514539","passed":true},{"actual":"-infinity","check":"boundary","expected":"-infinity","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true},{"actual":"-infinity","check":"negative zero","expected":"-infinity","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"near zero\", \"actual\": \"-690.7755279\", \"expected\": \"-41.588830834\", \"passed\": false}, {\"check\": \"far tail\", \"actual\": \"-7.0954741623e-23\", \"expected\": \"-7.0954741623e-23\", \"passed\": true}, {\"check\": \"midpoint\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"moderate\", \"actual\": \"-0.45867514539\", \"expected\": \"-0.45867514539\", \"passed\": true}, {\"check\": \"boundary\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}, {\"check\": \"negative zero\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.738,"exit_code":1,"observations":[{"actual":"arithmetic-error","check":"near zero","expected":"-41.588830834","passed":false},{"actual":"-7.0954741623e-23","check":"far tail","expected":"-7.0954741623e-23","passed":true},{"actual":"-0.69314718056","check":"midpoint","expected":"-0.69314718056","passed":true},{"actual":"-0.45867514539","check":"moderate","expected":"-0.45867514539","passed":true},{"actual":"-infinity","check":"boundary","expected":"-infinity","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true},{"actual":"-infinity","check":"negative zero","expected":"-infinity","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"near zero\", \"actual\": \"arithmetic-error\", \"expected\": \"-41.588830834\", \"passed\": false}, {\"check\": \"far tail\", \"actual\": \"-7.0954741623e-23\", \"expected\": \"-7.0954741623e-23\", \"passed\": true}, {\"check\": \"midpoint\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"moderate\", \"actual\": \"-0.45867514539\", \"expected\": \"-0.45867514539\", \"passed\": true}, {\"check\": \"boundary\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}, {\"check\": \"negative zero\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.989,"exit_code":0,"observations":[{"actual":"-41.588830834","check":"near zero","expected":"-41.588830834","passed":true},{"actual":"-7.0954741623e-23","check":"far tail","expected":"-7.0954741623e-23","passed":true},{"actual":"-0.69314718056","check":"midpoint","expected":"-0.69314718056","passed":true},{"actual":"-0.45867514539","check":"moderate","expected":"-0.45867514539","passed":true},{"actual":"-infinity","check":"boundary","expected":"-infinity","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true},{"actual":"-infinity","check":"negative zero","expected":"-infinity","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"near zero\", \"actual\": \"-41.588830834\", \"expected\": \"-41.588830834\", \"passed\": true}, {\"check\": \"far tail\", \"actual\": \"-7.0954741623e-23\", \"expected\": \"-7.0954741623e-23\", \"passed\": true}, {\"check\": \"midpoint\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"moderate\", \"actual\": \"-0.45867514539\", \"expected\": \"-0.45867514539\", \"passed\": true}, {\"check\": \"boundary\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}, {\"check\": \"negative zero\", \"actual\": \"-infinity\", \"expected\": \"-infinity\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}