"""Generate and check the explicit Pell orbit for Kopp's Conjecture 6. Run: python3 check_rossby_orbit.py --zonal 2 --terms 3 Each line is a JSON certificate with the Pell point and three wavevectors. The checks use exact integer arithmetic and rational frequencies. """ import argparse import json from fractions import Fraction from math import gcd def frequency(mode): """Return the rational frequency after removing the common factor.""" x, y = mode return Fraction(x, x * x + y * y) def orbit(zonal, terms): """Yield the requested number of triads with fixed nonzero zonal part.""" a = abs(zonal) sign = 1 if zonal > 0 else -1 discriminant = a * a + 1 base_p, base_r = 2 * a * a + 1, 2 * a pell_p, pell_r = 1, 0 previous_b = 0 for _ in range(terms): pell_p, pell_r = ( pell_p * base_p + discriminant * pell_r * base_r, pell_p * base_r + pell_r * base_p, ) w_factor = pell_p + pell_r if pell_r % (2 * a) or pell_p * pell_p - discriminant * pell_r**2 != 1: raise ArithmeticError("Pell equation or divisibility check failed") half_r = pell_r // 2 v = (w_factor - 1) // 2 b = 1 + discriminant * w_factor * half_r x = a * (b * half_r - v) y = -b * v - a * a * half_r output = (zonal, b) left = (sign * x, y) right = (output[0] - left[0], output[1] - left[1]) if not all(mode[0] for mode in (left, right, output)): raise ArithmeticError("Nonzonal condition failed") if b <= previous_b or (b - 1) % a or gcd(a, b) != 1: raise ArithmeticError("Growth, congruence, or coprimality check failed") if frequency(left) + frequency(right) != frequency(output): raise ArithmeticError("Exact resonance check failed") if gcd(gcd(*left), gcd(*output)) != 1: raise ArithmeticError("Primitivity check failed") yield {"pell_point": [pell_p, pell_r], "inputs": [left, right], "output": output} previous_b = b def main(): parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--zonal", type=int, default=2, help="fixed nonzero zonal wavenumber") parser.add_argument("--terms", type=int, default=1, help="number of positive powers") args = parser.parse_args() if args.zonal == 0: parser.error("--zonal must be nonzero") if args.terms < 1: parser.error("--terms must be positive") for certificate in orbit(args.zonal, args.terms): print(json.dumps(certificate)) if __name__ == "__main__": main()