#!/usr/bin/env python3 # Job #622: is the constant of condition (5.38) for the twin configuration EXACTLY K = 3, # as return #158 states? # # (5.38), as #158 paraphrases it: for all 2 <= w < z, # V(w)/V(z) <= K (log z / log w)^kappa, V(t) = prod_{p 1 else 2_000_000 sieve = bytearray([1]) * (N + 1) sieve[0] = sieve[1] = 0 for i in range(2, int(N ** 0.5) + 1): if sieve[i]: sieve[i * i::i] = bytearray(len(sieve[i * i::i])) primes = [i for i in range(2, N + 1) if sieve[i]] print("primes up to %d: %d" % (N, len(primes))) Vb = {} # V_before[p] = prod_{q runmax_A: runmax_A, argw = A, z # the w that maximises must itself be < z; use the max over the previous primes only prev = primes[primes.index(z) - 1] if False else None best.append((runmax_A, argw, z)) # redo properly: for each z, the running max must exclude z itself runmax_A, argw = None, None res = [] for i, z in enumerate(primes): if runmax_A is not None: Vz = Vb[z] res.append((runmax_A / (Vz * math.log(z) ** 2), argw, z, Vz)) A = Vb[z] * math.log(z) ** 2 if runmax_A is None or A > runmax_A: runmax_A, argw = A, z res.sort(key=lambda r: -r[0]) print("\nlargest K* over z <= %d:" % N) for K, w, z, Vz in res[:12]: print(" K = %.8f at z = %-9d w = %-8d V(z) = %.10g" % (K, z, w, Vz)) print("\nK* = %.10f (claim: exactly 3)" % res[0][0]) over = [(K, w, z) for K, w, z, _ in res if K > 3.0] print("pairs with K > 3: %d %s" % (len(over), over[:6]))