#!/usr/bin/env python3 """Job #1006 - run BOTH rung-pair readings on the control ladder (route 9 pursuit). The control, as the route states it: h(n) = h(P(n)#) = OEIS A048670, published values only (64 terms, b-file, up to p_64 = 311), with beta = 1 and a conjectured delta = 2 + o(1) (Maier-Pomerance, as recorded in exponent-control.md). The served G2 ladder gave a 3-base test at reach 82; the control gives the same readers at reach 312. The ladder and the defect, exactly as return #400 defines them: Ghat(x) = ladder value at the largest rung <= x D(b,k) = ln Ghat(b^(k+1)) - ln Ghat(b^k) - ln Ghat(b) Under Ghat(n) = c n^beta (ln n)^delta this is D(b,k) = -ln c + delta ln(1+1/k): affine in ln(1+1/k) with slope exactly delta, and the NUMERATOR N(b) = D(b,1) - D(b,2) = delta ln(4/3) is b-FREE, so its spread over bases is a model falsifier needing no control and no regression. PRE-REGISTERED READINGS (fixed before running, from the job's own statement of them): control PASSES if reader A and reader B agree within twice the perturbed-law margin for the same reach and bases, both are positive, and N(b) is flat in b; control FAILS if it drifts or splits the way the served G2 ladder does. Readers: A(b) = N(b)/ln(4/3) (rung pair (1,2) at one base); B(b) = least-squares slope of D(b,k) on ln(1+1/k), k = 1..k_max(b) (rung regression at one base). Published values only: no enumeration, no new ladder values, no recomputation of h. """ import json import math import sys TEXT = open('b048670.txt', encoding='utf-8').read().split() A = [0] + [int(TEXT[2 * i + 1]) for i in range(len(TEXT) // 2)] # A[k] = a(k), k = 1.. PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311] REACH = 312 def control_lg(x): """ln of the control ladder at the largest published prime rung <= x.""" k = 0 for i, p in enumerate(PRIMES): if p <= x: k = i + 1 else: break if k == 0: raise ValueError('x below the first rung: %r' % x) return math.log(A[k]) def kmax_of(b, reach): k = 1 while b ** (k + 2) <= reach: k += 1 return k def reader_b(lg, b, kmax): xs = [math.log(1 + 1 / k) for k in range(1, kmax + 1)] ys = [lg(b ** (k + 1)) - lg(b ** k) - lg(b) for k in range(1, kmax + 1)] n = len(xs) mx, my = sum(xs) / n, sum(ys) / n sxy = sum((x - mx) * (y - my) for x, y in zip(xs, ys)) sxx = sum((x - mx) ** 2 for x in xs) slope = sxy / sxx resid = [y - (my + slope * (x - mx)) for x, y in zip(xs, ys)] return slope, max(abs(r) for r in resid), ys def report(name, lg, bases, reach): rows = [] for b in bases: kmax = kmax_of(b, reach) if kmax < 2: continue d1 = lg(b ** 2) - 2 * lg(b) d2 = lg(b ** 3) - lg(b ** 2) - lg(b) num = d1 - d2 # b-free under (P) a_hat = num / math.log(4.0 / 3.0) slope, resid, dvals = reader_b(lg, b, kmax) rows.append({'b': b, 'kmax': kmax, 'numerator': num, 'A': a_hat, 'B': slope, 'disagreement': a_hat - slope, 'B_max_abs_resid': resid, 'D_values': dvals}) nums = [r['numerator'] for r in rows] dis = [abs(r['disagreement']) for r in rows] return {'object': name, 'reach': reach, 'rows': rows, 'numerator_spread': (max(nums) - min(nums)) if nums else None, 'max_abs_disagreement': max(dis) if dis else None} def perturbed(delta, beta, pert=0.35, c=0.37): return lambda x: math.log(c * x ** beta * (math.log(x) ** delta) * (1 + pert / math.log(x))) def main(): print('# Job #1006 - control run: A048670 (Jacobsthal on primorials), published values only') print('# terms 1..%d, largest rung %d, reach %d; beta = 1, conjectured delta = 2 + o(1)' % (len(A) - 1, PRIMES[-1], REACH)) print('# pre-registered: control PASSES iff |A-B| <= 2x the perturbed-law margin for the') print('# same reach and bases, both readings positive, and the numerator flat in b.') print('') bases = [2, 3, 4, 5, 6] out = {} out['control'] = report('A048670 control', control_lg, bases, REACH) # the same reach and bases on the deliberately perturbed law, at the control's beta = 1 out['perturbed_beta1_delta2'] = report('perturbed beta=1 delta=2 (control params)', perturbed(2.0, 1.0), bases, REACH) out['perturbed_beta1_delta05'] = report('perturbed beta=1 delta=0.5', perturbed(0.5, 1.0), bases, REACH) # and at the served G2 ladder's own beta, for comparability with the recorded 0.0459 out['perturbed_beta185_delta2'] = report('perturbed beta=1.85 delta=2 (G2 params)', perturbed(2.0, 1.85), bases, REACH) print('object reach bases numer.spread max|A-B| A range') for key in ('control', 'perturbed_beta1_delta2', 'perturbed_beta1_delta05', 'perturbed_beta185_delta2'): r = out[key] ar = [x['A'] for x in r['rows']] print(' %-34s %5d %6d %12.4f %9.4f [%.3f, %.3f]' % (r['object'], r['reach'], len(r['rows']), r['numerator_spread'], r['max_abs_disagreement'], min(ar), max(ar))) print('') print('## Per-base detail (control)') print(' b k_max N(b)=D(b,1)-D(b,2) A B A-B B resid') for r in out['control']['rows']: print(' %2d %5d %19.6f %8.3f %8.3f %8.4f %9.5f' % (r['b'], r['kmax'], r['numerator'], r['A'], r['B'], r['disagreement'], r['B_max_abs_resid'])) print('') print('## Per-base detail (perturbed, beta = 1, delta = 2) - the margin calibration') print(' b k_max N(b)=D(b,1)-D(b,2) A B A-B B resid') for r in out['perturbed_beta1_delta2']['rows']: print(' %2d %5d %19.6f %8.3f %8.3f %8.4f %9.5f' % (r['b'], r['kmax'], r['numerator'], r['A'], r['B'], r['disagreement'], r['B_max_abs_resid'])) print('') margin = out['perturbed_beta1_delta2']['max_abs_disagreement'] c = out['control'] print('## Verdict machinery (pre-registered reading)') print(' perturbed-law margin at these bases/reach (beta=1): max|A-B| = %.4f' % margin) print(' twice that margin = %.4f' % (2 * margin)) print(' control max|A-B| = %.4f -> %s' % (c['max_abs_disagreement'], 'within' if c['max_abs_disagreement'] <= 2 * margin else 'OUTSIDE')) print(' control readings all positive = %s' % all(r['A'] > 0 and r['B'] > 0 for r in c['rows'])) print(' control numerator spread = %.4f nats vs perturbed %.4f' % (c['numerator_spread'], out['perturbed_beta1_delta2']['numerator_spread'])) print('') print('Scope: the control is a published finite ladder read to x <= %d; nothing here bounds' % REACH) print('K, closes a proof gap, or says anything about twin-prime infinitude. beta = 1 and') print('delta = 2 + o(1) are the route\'s stated parameters for the control, not re-derived.') json.dump(out, open('control-readers.json', 'w'), indent=1, sort_keys=True) sys.stderr.write('done\n') if __name__ == '__main__': main()