← Wed, Nov 25 digest

A faster algorithm for extracting hexadecimal digits of π

read article ↗ hn thread ↗

A new algorithm extracts hexadecimal digits of pi faster than existing methods by rearranging Euler's series to share modular arithmetic and reduce divisions.

read it It offers genuine mathematical depth and clever low-level optimization tricks for high-performance arithmetic.

summary

Robert Smith introduces a faster algorithm for extracting arbitrary hexadecimal digits of pi without computing preceding ones by rearranging an old Euler series. By grouping terms with common and paired odd denominators, the algorithm shares modular exponentiations and significantly reduces expensive divisions. An AVX-512 implementation demonstrates roughly 40 to 65 percent faster wall-clock execution times compared to Huvent's formula.

key points

  1. Rearranges Euler's 1779 series to align odd denominators, enabling four powers of two to be evaluated with shared arithmetic.
  2. Cuts operations to roughly 7/27 divisions and 56/135 full modular exponentiations compared to Huvent's formula.
  3. Uses AVX-512 IFMA optimizations, including vector absolute values in Montgomery reduction, yielding major speedups.

who should read it

Software engineers and mathematicians interested in high-performance arithmetic and algorithmic optimization.

discussion positive

consensus

Commenters appreciate the clever algebraic rearrangement to reduce expensive division operations, with a referenced author providing helpful background context.

pushback

A minor debate occurred over the precise terminology and mathematical definition of percentage speedups.

best comment by nickcw ↗

The main boxed formula is equivalent to this Machin style formula for pi

pi = 4 arctan 4/7 + 4 arctan 1/8 + 2 arctan 8/31 + 2 arctan 1/32

Because each of the denominators in the arctans is a power or 2 or 1 different from a power of 2, we can make a BBP formula from it to calculate any hex digit of pi without calculating the previous ones.

I wrote a reasonably accessible account of how this works in https://scholarlycommons.pacific.edu/euleriana/vol3/iss1/3/ (which is referenced in the article!)

The boxed formula is exciting because it has been rearranged so that it has a single common …

It links the boxed formula to a Machin-style identity and shares historical context from a related academic paper.

Generated by an LLM from the article and thread. Check the sources before relying on it.