{"abstract":"Complementary log exponentials lose the distant tail.","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=0.0 if x < -40 else math.log(1-math.exp(x)) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-log1mexp-tail-cancellation","id":"FA-16136","implementations":{"attempt":{"sha256":"7e59fb088c677ec557f5a74cf872e21528737e416e99ac7b1499b4334799748e","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=0.0 if x < -40 else math.log(1-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"},"broken":{"sha256":"57f09f06024b32d955ac18bd2be67bec73d14ecdb7993ee668f21d696b2eb99a","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.log(1-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"},"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-tail-cancellation","generated_at":"2026-09-29T14:39:33.387116+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.log1p(-math.exp(x)).","root_cause":"Complementary log exponentials lose the distant tail. The faulty expression is result=math.log(1-math.exp(x)).","sha256":"dd081326dcd4684a5b131794b991e43d4660ae92043e0acd29e75fb78622ef56","title":"Complementary log exponentials lose the distant tail · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.273,"exit_code":1,"observations":[{"actual":"-41.588830834","check":"near zero","expected":"-41.588830834","passed":true},{"actual":"0","check":"far tail","expected":"-7.0954741623e-23","passed":false},{"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\": \"-41.588830834\", \"expected\": \"-41.588830834\", \"passed\": true}, {\"check\": \"far tail\", \"actual\": \"0\", \"expected\": \"-7.0954741623e-23\", \"passed\": false}, {\"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":40.241,"exit_code":1,"observations":[{"actual":"-41.588830834","check":"near zero","expected":"-41.588830834","passed":true},{"actual":"0","check":"far tail","expected":"-7.0954741623e-23","passed":false},{"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\": \"-41.588830834\", \"expected\": \"-41.588830834\", \"passed\": true}, {\"check\": \"far tail\", \"actual\": \"0\", \"expected\": \"-7.0954741623e-23\", \"passed\": false}, {\"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":41.187,"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"}