mp_real_partitions_hrr, _mp_real_partitions_hrr
#include <flint/mp_real.h>mp_real_partitions_hrr reads p(n) from a table for n < 128, uses the pentagonal recurrence while p(n) fits a word (n < 417 on 64-bit machines), and otherwise the Hardy–Ramanujan–Rademacher formula [Rademacher1937] [Joh2012]
with A_k(n) from arith_hrr_expsum_factored, N and the bound for R_N from partitions_rademacher_bound, and each term at the precision it contributes at. Terms of at most about 200 bits are evaluated in batches of dfloat balls, the others in mp_real balls, with \exp(z_k) obtained as the k-th root of \exp(z_1) (computed by mp_real_exp_notab_squaring or, at huge precision, mp_real_exp_agm). The resulting ball is resolved by mp_real_unique_integer (Integers from balls).
With several threads (flint_set_num_threads, from n = 10^8) the constants are computed once with the whole thread budget, and the terms are summed in ranges of k of about equal cost, each into its own accumulator. The peak memory is about that of computing \pi to the same precision.
_mp_real_partitions_hrr uses the formula for every n \ge 2; flags is a combination of MP_REAL_PARTITIONS_NO_DFLOAT (all terms in mp_real) and MP_REAL_PARTITIONS_TEST (the rarely taken paths at any n), for testing. partitions_fmpz_fmpz in partitions.h calls these functions. The method is described in Computing the partition function.
References#
- [Rademacher1937] Rademacher, Hans : On the partition function p(n) Proc. London Math. Soc vol. 43 (1937) 241–254
- [Joh2012] F. Johansson, "Efficient implementation of the Hardy-Ramanujan-Rademacher formula", LMS Journal of Computation and Mathematics, Volume 15 (2012), 341-359, http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=8710297
The FLINT team, “mp_real_partitions_hrr, _mp_real_partitions_hrr (mp_real.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mp_real/mp_real_partitions_hrr.html (generated 2026-10-20).
@misc{flint-doc-mp-real-mp-real-partitions-hrr,
author = {{The FLINT team}},
title = {{mp\_real\_partitions\_hrr, \_mp\_real\_partitions\_hrr (mp\_real.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/mp_real/mp_real_partitions_hrr.html},
note = {Generated 2026-10-20}
}