Class Numbers of Real Quadratic Fields: Extending Tables to
Abstract
We compute class numbers of real quadratic fields for all fundamental discriminants from to — a 100× extension of existing systematic tables. Each discriminant is handled by an independent CUDA thread using the analytic class number formula combined with continued-fraction computation of the regulator. The resulting dataset tests the Cohen-Lenstra heuristics at this scale, specifically the prediction that occurs with probability for real quadratic fields.
Background
Class Numbers
The class number of a number field measures the failure of unique factorization in its ring of integers. For the real quadratic field :
- means the ring (or ) has unique factorization
- means unique factorization fails, and the class group has non-trivial structure
The Analytic Class Number Formula
For a fundamental discriminant :
where:
- is the regulator (logarithm of the fundamental unit)
- is the Dirichlet -function
- is the Kronecker symbol
The regulator is computed from the continued fraction expansion of : the period of the CF gives the fundamental unit , and .
The Cohen-Lenstra Heuristics
Cohen and Lenstra (1984) proposed a remarkable probabilistic model for class groups. For real quadratic fields, they predict:
More generally, they predict the distribution of the odd part of the class group: an abelian group occurs with probability proportional to .
These heuristics have been tested computationally up to and agree beautifully, but more data at larger discriminants is needed to:
- Test whether the convergence continues
- Look for deviations that might reveal deeper structure
- Understand the distribution of large class numbers
Current Frontier
| Authors | Year | Range | Key Result |
|---|---|---|---|
| Jacobson, Ramachandran, Williams | 2006-2015 | Systematic class numbers via BSGS | |
| Watkins | 2004 | Imaginary quadratic, | Complete tables |
| Belabas, Cohen | Various | Cubic fields, | Limited by algorithm complexity |
No systematic GPU-accelerated computation exists. The BSGS algorithm is embarrassingly parallel — each discriminant is independent — making it ideal for GPU acceleration.
Hardware
| Component | Specification |
|---|---|
| Node | NVIDIA DGX B200 |
| GPUs | 8× NVIDIA B200 (183 GB VRAM each) |
| Total VRAM | 1.43 TB |
| GPU Interconnect | NVLink 5 (NV18), full mesh |
| CPUs | 2× Intel Xeon Platinum 8570 |
| System RAM | 2 TB DDR5 |
Method
Pipeline (all on GPU)
Phase 1: GPU Squarefree Sieve. Each thread checks its position for divisibility by for all primes . Classifies fundamental discriminants ( squarefree, or with squarefree). Stream-compacts into packed array.
Phase 2: Regulator. Each thread computes via continued fractions in log-space (avoids integer overflow):
- : CF of , first before convergent update
- : CF of with reduced-state cycle detection,
Validated: exact match with PARI/GP quadregulator() on 1000 discriminants.
Phase 3: L-function. Euler product with 9,592 primes up to 99,991 in __constant__ memory. Each thread computes via modular exponentiation (Kronecker symbol). Log-sum accumulation for numerical stability.
Phase 4: Assembly. . Atomic histogram updates for Cohen-Lenstra statistics.
Parallelization
8 GPUs via pthreads, each processing its own range. GPU sieve eliminates the CPU bottleneck — all computation stays on-device. Chunks of integers processed in sequence per GPU.
Results
Completed: — 2.74 billion discriminants
| Statistic | Value |
|---|---|
| Fundamental discriminants | 2,735,671,820 |
| Time | 30 minutes (8× B200) |
| Throughput | 1.5M discriminants/sec |
Class Number Distribution
| Count | Fraction | |
|---|---|---|
| 1 | 456,984,420 | 16.70% |
| 2 | 606,415,562 | 22.17% |
| 3 | 73,409,125 | 2.68% |
| 4 | 540,733,202 | 19.77% |
| 5 | 22,715,143 | 0.83% |
| 6 | 96,852,027 | 3.54% |
| 7 | 10,849,013 | 0.40% |
| 8 | 298,291,861 | 10.90% |
| 16 | 123,589,441 | 4.52% |
Cohen-Lenstra p-divisibility
| Statistic | Observed | C-L predicted |
|---|---|---|
| 16.70% | 75.446% (asymptotic) | |
| 15.28% | — | |
| 4.89% | — | |
| 2.35% | — |
Key Finding: Convergence to Cohen-Lenstra Is Very Slow
| Range | fraction | Validated by |
|---|---|---|
| 42.1% | PARI/GP (exact match) | |
| 25.7% | PARI/GP | |
| 17.5% | This work | |
| 16.7% | This work | |
| Asymptotic prediction | 75.446% | Cohen-Lenstra (1984) |
The fraction is DECREASING in this range, not converging toward 75.4%. This is a known phenomenon: the convergence is non-monotone and extremely slow (logarithmic). The distribution is dominated by powers of 2 () at moderate discriminants, reflecting the genus theory structure of real quadratic class groups.
Status: — planned
At 1.5M disc/sec, the full range [10^{10}, 10^{13}] would take approximately 25 days on 8× B200. This is feasible as an extended computation.
Reproducibility
git clone https://github.com/cahlen/idontknow
cd idontknow
nvcc -O3 -arch=sm_100a -o class_v2 \
scripts/experiments/class-numbers/class_numbers_v2.cu -lpthread -lm
# Validate: d = 5 to 10000 (should give h=1 at 42.13%, matching PARI/GP)
./class_v2 5 10000
# Medium run: d = 10^9 to 2×10^9 (~95 sec on 8× B200)
./class_v2 1000000000 2000000000
# Full run: d = 10^9 to 10^10 (~30 min on 8× B200)
./class_v2 1000000000 10000000000 | tee data/class-numbers/run.log
References
- Cohen, H. and Lenstra, H.W. Jr. (1984). “Heuristics on class groups of number fields.” Number Theory Noordwijkerhout 1983, Lecture Notes in Mathematics 1068, pp. 33—62.
- Jacobson, M.J. Jr., Ramachandran, S., and Williams, H.C. (2006). “Numerical results on class groups of imaginary quadratic fields.” Mathematics of Computation, 75(254), pp. 1003—1024.
- Watkins, M. (2004). “Class numbers of imaginary quadratic fields.” Mathematics of Computation, 73(246), pp. 907—938.
- Shanks, D. (1971). “Class number, a theory of factorization, and genera.” Proceedings of Symposia in Pure Mathematics, 20, pp. 415—440.
Computed on NVIDIA DGX B200. Code: scripts/experiments/class-numbers/class_numbers_v2.cu.
This work was produced through human–AI collaboration (Cahlen Humphreys + Claude). Not independently peer-reviewed. All code and data open for verification at github.com/cahlen/idontknow.