Folding the Plouffe-Bellard Digit-Extraction Scheme for : A Legendre-Symbol Block Identity and an Variant
Version 1 / Dec 05, 2026 / CC BY 4.0
Abstract
The algorithm of Plouffe and Bellard computes the digits of at positions in any base from the series in operations on machine words and words of memory: for each of the primes with , it runs a loop of length .
We prove that for every prime with , the sum of the contributions of all complete blocks collapses to the Legendre symbol , by the identity . The loop of length is replaced by a partial sum of at most terms, where , and the total number of loop iterations drops from to at most , a reduction factor of at least . Each remaining partial sum is a prefix or suffix sum of a hypergeometric sequence modulo ; computing it with the baby-step giant-step method of Bostan, Gaudry, and Schost takes operations and gives a total complexity of operations.
The proposed framework returns the correct digits in all verification cases; on benchmarks with , it is to times faster than the standard loop of the Plouffe--Bellard scheme on the same series, and the measured execution time of a single tail sum scales strictly like up to . The complete source code, verification test suites, and benchmarks are made available.
References
- D. H. Bailey, P. B. Borwein, S. Plouffe, On the rapid computation of various polylogarithmic constants, Math.\ Comp.\ 66 (1997), 903--913.
- S. Plouffe, On the computation of the -th decimal digit of various transcendental numbers, 1996, arXiv:0912.0303 [math.NT]. https://arxiv.org/abs/0912.0303arXiv
- F. Bellard, Computation of the 'th digit of in any base in , 1997. https://bellard.org/pi/pi_n2/pi_n2.htmllink
- A. Bostan, P. Gaudry, É. Schost, Linear recurrences with polynomial coefficients and application to integer factorization and Cartier--Manin operator, SIAM J.\ Comput.\ 36 (2007), 1777--1806.
- A. Granville, Binomial coefficients modulo prime powers, Canad.\ Math.\ Soc.\ Conf.\ Proc.\ 20 (1997), 253--275.
- J. B. Rosser, L. Schoenfeld, Approximate formulas for some functions of prime numbers, Illinois J.\ Math.\ 6 (1962), 64--94.
- D. G. Cantor, E. Kaltofen, On fast multiplication of polynomials over arbitrary algebras, Acta Inform.\ 28 (1991), 693--701.
- M. Kim, source code: pi_decimal_digits.py, verify_pi_digits.py, bench_pi_digits.py. https://github.com/tankwars92/pi_decimal_digits.link