math.NT — Number Theory
Folding the Plouffe-Bellard Digit-Extraction Scheme for : A Legendre-Symbol Block Identity and an Variant
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.