Prime Convergents of Continued Fractions
Background
For an irrational number , the -th convergent has numerators and denominators that grow exponentially with . In 1939, Erdos and Mahler showed that for almost all , the greatest prime factor of the denominator increases rapidly:
Humphreys (2013, NCUR/Boise State) extended this to the numerator via Theorem 3.5 and Corollary 3.6, showing the corresponding result for . The original experimental verification was limited to 500 convergents of and for , computed in Maple.
What This Experiment Does
This GPU experiment massively extends the computational verification:
- Random CF sampling: Generate hundreds of thousands of random CF expansions (partial quotients drawn from the Gauss-Kuzmin distribution) and compute all convergents until overflow
- Primality testing: GPU-parallel deterministic Miller-Rabin (12 witnesses, valid for all 64-bit integers) on every numerator and denominator
- Greatest prime factor: Trial division by primes up to 997 plus Miller-Rabin on the cofactor
- Doubly-prime census: Count convergents where both and are prime — extending the observation from Humphreys (2013) Section 4
Each GPU thread handles one complete CF sequence independently. The B200’s 183 GB VRAM allows millions of simultaneous sequences.
Method
- Convergent recurrence: , , computed in 128-bit arithmetic (overflow at depth ~38-42 for typical CFs with Gauss-Kuzmin partial quotients)
- Primality: Deterministic Miller-Rabin with witnesses {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}, sufficient for all
- GPF computation: Trial division by first 168 primes (up to 997), then primality check on remainder
- Modes: Random Gauss-Kuzmin CFs, CF of (known pattern), CF of (50 known terms + random)
Reproduce
nvcc -O3 -arch=sm_90 -o prime_convergents scripts/experiments/prime-convergents/prime_convergents.cu -lm
./prime_convergents 100000 500 0 # 100K random CFs, depth 500
./prime_convergents 1 500 1 # CF of e, depth 500
./prime_convergents 1 500 2 # CF of pi, depth 500
References
- Erdos, P. and Mahler, K. (1939). “Some Arithmetical Properties Of The Convergents Of A Continued Fraction.” London Math. Soc., pp. 12-18.
- Humphreys, C. (2013). “Prime Numbers and the Convergents of a Continued Fraction.” Proceedings of NCUR 2013, University of Wisconsin La Crosse.
- Gauss, C.F. (1812). Disquisitiones generales circa seriem infinitam.
Extends Humphreys (2013) with GPU computation. Human-AI collaboration (Cahlen Humphreys + Claude). All code and data open.