"""Independent check of return 264's bounded numerical claim, Python stdlib.""" from fractions import Fraction as Q from pathlib import Path import hashlib import json import math ROOT = Path(__file__).parent # Derive in b directly, independently of the submitted t-coordinate script. # The positive main term requires a > b/(2 log(b-1)). The infimum uses equality. def boundary(b): return b / (2 * math.log(b - 1)) def derivative(b): t = math.log(b - 1) return 1 + (t - b / (b - 1)) / (2 * t * t) lo, hi = 2.9, 3.0 assert derivative(lo) < 0 < derivative(hi) for _ in range(70): mid = (lo + hi) / 2 if derivative(mid) < 0: lo = mid else: hi = mid b = (lo + hi) / 2 a = boundary(b) k = max(a + b, 2 * a) equal = 2 * (1 + math.sqrt(math.e)) assert 1 < a < 3 and 2 < b < 4 and a < b assert abs(k - 5.158064680330098) < 2e-14 assert abs(equal - 5.297442541400256) < 2e-14 # Include the branch where a >= b and the upper-upper product sets the cost. grid_min = min( max(boundary(v) + v, 2 * boundary(v)) for i in range(1, 20001) if 1 <= boundary(v := 2 + i / 10000) <= 3 ) assert grid_min >= k - 1e-13 and grid_min - k < 1e-8 # Check actual indicators, allowing negative lower approximants. The two # slack identities prove validity, beyond this finite rational fixture. checked = 0 for x1 in [Q(0), Q(1)]: for x2 in [Q(0), Q(1)]: for l1 in [Q(-1), Q(0), Q(1, 2), Q(1)]: for l2 in [Q(-1), Q(0), Q(1, 2), Q(1)]: if l1 > x1 or l2 > x2: continue for u1 in [Q(1), Q(3, 2), Q(2)]: for u2 in [Q(1), Q(3, 2), Q(2)]: true_rhs = u1*x2 + x1*u2 - u1*u2 minorant_rhs = u1*l2 + l1*u2 - u1*u2 assert x1*x2 - true_rhs == (u1-x1)*(u2-x2) >= 0 assert true_rhs - minorant_rhs == u1*(x2-l2)+u2*(x1-l1) >= 0 checked += 1 # Store tolerances rather than platform-sensitive last-bit float output. out = { "independent_coordinate": "b, derivative of b + b/(2 log(b-1))", "price_matches_264_within": "2e-14", "both_published_branches": True, "upper_upper_cost_included": True, "dense_grid_points": 20000, "dense_grid_min_within": "1e-8", "rational_indicator_substitution_cases": checked, "scope": "Initial-branch symmetric component levels only; no arbitrary-weight optimum, new exponent, or translated-window remainder." } target = ROOT / "check-transfer-690-result.json" target.write_text(json.dumps(out, indent=2) + "\n") print(json.dumps(out, indent=2)) print("sha256", hashlib.sha256(target.read_bytes()).hexdigest())