A faster algorithm for extracting hexadecimal digits of π stylewarning.com · 12 ...
HN Best 200 @best
A faster algorithm for extracting hexadecimal digits of π stylewarning.com · 12 points · 0 comments · HN thread
TL;DR Robert Smith presents an algorithm for extracting hexadecimal digits of π at an arbitrary offset without computing the preceding digits, built on a rearranged Euler series. He reports roughly 61% fewer divisions and 38% fewer full modular exponentiations than Huvent's eight-term formula, and about 40% less wall-clock time in an AVX-512 IFMA implementation.
- The method rearranges an 1779 Euler series by collecting terms with odd denominators, so each odd denominator's fractions are summed before a single division.
- Remainders for the four powers of two are derived from one starting exponentiation plus a step 2^k mod M and multiplications, reducing the number of full modular exponentiations.
- Pairing a denominator M with 3M lets two denominators share modular arithmetic modulo 3M, so one division covers both.
- Reported metrics: about 2.41 bits per full modular exponentiation and 3.86 bits per division, versus 1.50 and 1.50 for Huvent's formula.
- Implementation timings for extracting 12 hex digits show 10% to 66% speedups over Huvent across 1 and 32 threads, with a 1,000,000,000,000-digit offset run taking about 521 s versus 846 s.
- The author notes Euler's series needs more fractions per bit when evaluated term by term, so the gain comes from sharing arithmetic across denominators.
Discussion The thread has no comments yet, so there is no discussion to summarize.
#pi #digitExtraction #BBPFormula #modularArithmetic #algorithms