{"abstract":"Log ratio subtracts close logarithms at large magnitude.","category":"Floating-point arithmetic","checks":8,"contract":"Evaluate log(a/b) for positive finite endpoints without overflowing an intermediate quotient and without cancellation for nearby operands. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.","evaluation_group":"s3-float-log-ratio","failed_approach":"The attempted local correction result=math.log(a/b) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-log-ratio-near-log-cancellation","id":"FA-17036","implementations":{"attempt":{"sha256":"3fd5f92501bcb6aca34e0d9e5e9d9601078b3bbb298f39496162eff2a4400cfb","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(a,b):\n    try:\n        if a<=0 or b<=0: return 'domain'\n        if a==b: return '0'\n        r=(a-b)/b\n        if abs(r)<0.5:\n            result=math.log(a/b)\n        else:\n            result=math.log(a)-math.log(b)\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('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))\ncheck('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))\ncheck('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))\ncheck('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))\ncheck('normal', solve(float(N+1),1.0), render(math.log(N+1)))\ncheck('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))\ncheck('equal', solve(float(N),float(N)), \"0\")\ncheck('invalid', solve(0.0,float(N)), \"domain\")\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":"918cf807f484aa9ce8ea73c80dd00b420866a26c45fe4e33e05a7a6e57ec9b95","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(a,b):\n    try:\n        if a<=0 or b<=0: return 'domain'\n        if a==b: return '0'\n        r=(a-b)/b\n        if abs(r)<0.5:\n            result=math.log(a)-math.log(b)\n        else:\n            result=math.log(a)-math.log(b)\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('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))\ncheck('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))\ncheck('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))\ncheck('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))\ncheck('normal', solve(float(N+1),1.0), render(math.log(N+1)))\ncheck('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))\ncheck('equal', solve(float(N),float(N)), \"0\")\ncheck('invalid', solve(0.0,float(N)), \"domain\")\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":"7da1be31e2ee6da6c7190c7986b0341a1ff43375807b435544d6a8b7467aa487","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(a,b):\n    try:\n        if a<=0 or b<=0: return 'domain'\n        if a==b: return '0'\n        r=(a-b)/b\n        if abs(r)<0.5:\n            result=math.log1p(r)\n        else:\n            result=math.log(a)-math.log(b)\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('overflowing quotient', solve(N*1e300,1e-300), render(math.log(N*1e300)-math.log(1e-300)))\ncheck('underflowing quotient', solve(1e-300,N*1e300), render(math.log(1e-300)-math.log(N*1e300)))\ncheck('nearby moderate', solve(1.125,1.0), render(math.log(1.125)))\ncheck('nearby large', solve(math.nextafter(1e100,math.inf),1e100), render(math.log1p((math.nextafter(1e100,math.inf)-1e100)/1e100)))\ncheck('normal', solve(float(N+1),1.0), render(math.log(N+1)))\ncheck('reverse', solve(1.0,float(N+1)), render(-math.log(N+1)))\ncheck('equal', solve(float(N),float(N)), \"0\")\ncheck('invalid', solve(0.0,float(N)), \"domain\")\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-log-ratio-near-log-cancellation","generated_at":"2026-09-29T14:39:42.310872+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(r).","root_cause":"Log ratio subtracts close logarithms at large magnitude. The faulty expression is result=math.log(a)-math.log(b).","sha256":"94d79ae0b2d69e6e988dbefa1d552d9eebc9fbeb4ea44011f2d0bee91d55278e","title":"Log ratio subtracts close logarithms at large magnitude · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.535,"exit_code":1,"observations":[{"actual":"1381.5510558","check":"overflowing quotient","expected":"1381.5510558","passed":true},{"actual":"-1381.5510558","check":"underflowing quotient","expected":"-1381.5510558","passed":true},{"actual":"0.11778303566","check":"nearby moderate","expected":"0.11778303566","passed":true},{"actual":"2.2204460493e-16","check":"nearby large","expected":"1.9426688922e-16","passed":false},{"actual":"0.69314718056","check":"normal","expected":"0.69314718056","passed":true},{"actual":"-0.69314718056","check":"reverse","expected":"-0.69314718056","passed":true},{"actual":"0","check":"equal","expected":"0","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"overflowing quotient\", \"actual\": \"1381.5510558\", \"expected\": \"1381.5510558\", \"passed\": true}, {\"check\": \"underflowing quotient\", \"actual\": \"-1381.5510558\", \"expected\": \"-1381.5510558\", \"passed\": true}, {\"check\": \"nearby moderate\", \"actual\": \"0.11778303566\", \"expected\": \"0.11778303566\", \"passed\": true}, {\"check\": \"nearby large\", \"actual\": \"2.2204460493e-16\", \"expected\": \"1.9426688922e-16\", \"passed\": false}, {\"check\": \"normal\", \"actual\": \"0.69314718056\", \"expected\": \"0.69314718056\", \"passed\": true}, {\"check\": \"reverse\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"equal\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.446,"exit_code":1,"observations":[{"actual":"1381.5510558","check":"overflowing quotient","expected":"1381.5510558","passed":true},{"actual":"-1381.5510558","check":"underflowing quotient","expected":"-1381.5510558","passed":true},{"actual":"0.11778303566","check":"nearby moderate","expected":"0.11778303566","passed":true},{"actual":"0","check":"nearby large","expected":"1.9426688922e-16","passed":false},{"actual":"0.69314718056","check":"normal","expected":"0.69314718056","passed":true},{"actual":"-0.69314718056","check":"reverse","expected":"-0.69314718056","passed":true},{"actual":"0","check":"equal","expected":"0","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"overflowing quotient\", \"actual\": \"1381.5510558\", \"expected\": \"1381.5510558\", \"passed\": true}, {\"check\": \"underflowing quotient\", \"actual\": \"-1381.5510558\", \"expected\": \"-1381.5510558\", \"passed\": true}, {\"check\": \"nearby moderate\", \"actual\": \"0.11778303566\", \"expected\": \"0.11778303566\", \"passed\": true}, {\"check\": \"nearby large\", \"actual\": \"0\", \"expected\": \"1.9426688922e-16\", \"passed\": false}, {\"check\": \"normal\", \"actual\": \"0.69314718056\", \"expected\": \"0.69314718056\", \"passed\": true}, {\"check\": \"reverse\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"equal\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.081,"exit_code":0,"observations":[{"actual":"1381.5510558","check":"overflowing quotient","expected":"1381.5510558","passed":true},{"actual":"-1381.5510558","check":"underflowing quotient","expected":"-1381.5510558","passed":true},{"actual":"0.11778303566","check":"nearby moderate","expected":"0.11778303566","passed":true},{"actual":"1.9426688922e-16","check":"nearby large","expected":"1.9426688922e-16","passed":true},{"actual":"0.69314718056","check":"normal","expected":"0.69314718056","passed":true},{"actual":"-0.69314718056","check":"reverse","expected":"-0.69314718056","passed":true},{"actual":"0","check":"equal","expected":"0","passed":true},{"actual":"domain","check":"invalid","expected":"domain","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"overflowing quotient\", \"actual\": \"1381.5510558\", \"expected\": \"1381.5510558\", \"passed\": true}, {\"check\": \"underflowing quotient\", \"actual\": \"-1381.5510558\", \"expected\": \"-1381.5510558\", \"passed\": true}, {\"check\": \"nearby moderate\", \"actual\": \"0.11778303566\", \"expected\": \"0.11778303566\", \"passed\": true}, {\"check\": \"nearby large\", \"actual\": \"1.9426688922e-16\", \"expected\": \"1.9426688922e-16\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"0.69314718056\", \"expected\": \"0.69314718056\", \"passed\": true}, {\"check\": \"reverse\", \"actual\": \"-0.69314718056\", \"expected\": \"-0.69314718056\", \"passed\": true}, {\"check\": \"equal\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"invalid\", \"actual\": \"domain\", \"expected\": \"domain\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}