# cramer_identity.py # Ancillary file of: "A remark on the independence step in Shkredov's approach to Zaremba's conjecture" # Author: David Niedbala Giraudin (independent researcher, France), ORCID 0009-0009-1526-1178. # Prepared with the assistance of an AI model (Claude, Anthropic) under the author's direction. # # What this script CHECKS (exact integer arithmetic, fixed seeds, no dependency): # Part 1. For convergent denominators w = K(r1..rs) with numerators wh = K(r2..rs), and # d(x,y) = x*yh - y*xh (formula (70) of arXiv:2603.14116v2), for any integer b: # q*d(x,y) = y*(b*x - q*xh) - x*(b*y - q*yh) (Lemma 2.1 of the note) # d(y,z)*x + d(z,x)*y + d(x,y)*z = 0 (formula (75)) # and the bound |d(x,y)| <= (x*|b*y-q*yh| + y*|b*x-q*xh|)/q. # Part 2. On random positive integers with q = r^2 a perfect square (so sqrt(q) = r is exact), # whenever the two inequalities (5) of the note hold, # t*x*z < q^(3/2)/(6912 M^2) and I^2*x*y^2*z*t < q^(5/2)/(27648 M^2), # the squared bounds of Propositions 2.2 and 2.3 are at most the squared C_j of (4). # What it does NOT do: it does not prove the propositions (they are proved in the note), and it # does not check anything about the text of arXiv:2603.14116v2 itself. import random from fractions import Fraction as F def convergents(a, q): """list of (numerator, denominator) of the convergents of a/q (0 < a < q)""" r0, r1, pm2, pm1, qm2, qm1, out = q, a, 1, 0, 0, 1, [] while r1: c = r0 // r1 pm2, pm1 = pm1, c * pm1 + pm2 qm2, qm1 = qm1, c * qm1 + qm2 out.append((pm1, qm1)); r0, r1 = r1, r0 - c * r1 return out def d(x, xh, y, yh): return x * yh - y * xh def self_test(): cv = convergents(7, 25) assert cv[0] == (1, 3) and cv[-1] == (7, 25) assert d(3, 1, 25, 7) == 3 * 7 - 25 * 1 print("self-test passed", flush=True) def part1(): random.seed(7); q = 1000000000039; checked = 0 for trial in range(3000): a = random.randrange(1, q); b = (a + random.randrange(1, 10 ** 4)) % q; c = (b + random.randrange(1, 10 ** 4)) % q X = [w for w in convergents(a, q) if w[1] > 10 ** 6] Y = [w for w in convergents(b, q) if 10 ** 3 < w[1] < 10 ** 6] Zc = [w for w in convergents(c, q) if 10 ** 3 < w[1] < 10 ** 6] if not (X and Y and Zc): continue (xh, x), (yh, y), (zh, z) = X[0], Y[-1], Zc[-1] for (u, uh), (v, vh) in (((x, xh), (y, yh)), ((y, yh), (z, zh)), ((z, zh), (x, xh))): lhs = d(u, uh, v, vh); num = v * (b * u - q * uh) - u * (b * v - q * vh) assert num == q * lhs assert abs(lhs) * q <= u * abs(b * v - q * vh) + v * abs(b * u - q * uh) assert d(y, yh, z, zh) * x + d(z, zh, x, xh) * y + d(x, xh, y, yh) * z == 0 checked += 1 print(f"part 1: identity, (75) and residue bound verified exactly on {checked} configurations", flush=True) def isqrt_floor(n): import math return math.isqrt(n) def part2(): random.seed(11); kept = 0; tried = 0; kept0 = 0 while kept < 5000: tried += 1 r = random.randrange(10 ** 6, 10 ** 9); q = r * r # sqrt(q) = r M = random.randrange(1, 50); Mt = random.randrange(1, 50) y = random.randrange(3, r + 1); y0 = random.randrange(2, y + 1); z = random.randrange(1, y0) B1 = (r ** 3 - 1) // (6912 * M * M * z) # need t*x*z < r^3/(6912 M^2) if B1 < 1: continue x = random.randrange(1, B1 + 1) if random.random() < 0.5 else random.randrange(1, isqrt_floor(B1) + 2) if x > B1: continue t = random.randrange(1, B1 // x + 1) B2 = (r ** 5 - 1) // (27648 * M * M * x * y * y * z * t) # need I^2*x*y^2*z*t < r^5/(27648 M^2) Imax = isqrt_floor(B2) if Imax < 1: continue I = random.randrange(1, Imax + 1) assert 6912 * M * M * t * x * z < r ** 3 and 27648 * M * M * I * I * x * y * y * z * t < r ** 5 kept += 1 C1sq = F(48 * r * z, t * x); C2sq = F(192 * I * I * x * z, t * r); C3sq = F(48 * r * x, t * z) # Proposition 2.2 (triple x, y, z) assert F(z * (r + 2 * I * y), q) ** 2 <= C1sq assert F(4 * I * x * z, q) ** 2 <= C2sq assert F(x * (r + 2 * I * y), q) ** 2 <= C3sq # Proposition 2.3 (triple x, y0, z): its hypotheses give x*z*t <= sqrt(q)*y0^2 <= 12*Mt^2*y0^2*sqrt(q) if x * z * t <= r * y0 * y0: kept0 += 1 assert (F(2 * I * y0 * z, q) + F(z, Mt * y0)) ** 2 <= C1sq assert (F(2 * I * y0 * x, q) + F(x, Mt * y0)) ** 2 <= C3sq if kept % 1000 == 0: print(f" ... {kept} parameter sets", flush=True) print(f"part 2: box inequalities of Proposition 2.2 verified exactly on {kept} parameter sets,", flush=True) print(f" those of Proposition 2.3 on the {kept0} sets satisfying x*z*t <= sqrt(q)*y0^2 ({tried} drawn)", flush=True) if __name__ == "__main__": self_test(); part1(); part2() print("ALL CHECKS PASSED", flush=True)