#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Route 162 rescue, step 1: does an Omega-truncated Mobius bracket pair have a POSITIVE pair main term? The failed family (return #1743) used U = 1 and L = 1 - omega(gcd(n,P(z))): its coefficients are a_1 = 1, a_p = -1, i.e. the Mobius truncation at Omega-level 1 on the LOWER side and the trivial UPPER side. Its consumer main term was M = 1 - 2 sum_{p 0 (impossible, p does not divide 2); exactly one -> 1/p; neither -> 1 p = 2: 2|r <=> 2|(r+2), so 'either or both' -> 1/2, neither -> 1 The true rough-pair main term is V(z) = (1/2) * prod_{2 1 else 1 for d2 in ds: mu2 = (-1) ** len(prime_factors(d2)) if d2 > 1 else 1 tot += mu1 * mu2 * rho(d1, d2) return tot def prime_factors(n): ps, m = [], n for p in range(2, n + 1): if m % p == 0: ps.append(p) while m % p == 0: m //= p return ps def V(z): v = Fraction(1, 2) for p in primes_lt(z): if p != 2: v *= Fraction(p - 2, p) return v print(f"{'z':>4} {'pi':>3} {'r':>2} {'T (exact)':>22} {'T float':>10} {'V(z) true':>12} {'T>0':>5}") for z in (5, 7, 11, 13, 17, 19): v = V(z) for r in (1, 2, 3, 4, 5): t = T(z, r) print(f"{z:>4} {len(primes_lt(z)):>3} {r:>2} {str(t):>22} {float(t):>10.6f} {float(v):>12.6f} {str(t > 0):>5}") print()