# A new algorithm skips ahead to π's hex digits with 61% fewer divisions

Original title: A faster algorithm for extracting hexadecimal digits of π

> Hacker News story 50638075 · language: en · submitted 2026-11-25
> Web version: https://zeli.app/story/50638075
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 74 · by [vinhnx](<https://news.ycombinator.com/user?id=vinhnx>) · 💬 5
[original](<https://www.stylewarning.com/posts/faster-digit-extraction/>) · [HN discussion](<https://news.ycombinator.com/item?id=50638075>)

## Summary

Robert Smith presents a method for extracting hexadecimal digits of π without computing earlier ones, beating BBP, Bellard, and Huvent on operation count. By lining up denominators in an Euler-derived series, four powers of two share a single division, and pairing moduli like 13 and 39 lets two denominators share the same exponentiations. Benchmarks with AVX-512 IFMA show roughly 62% faster extraction at a trillion skipped digits.

## Key quote

> Eight powers of two over two different denominators can share two full exponentiations and a single division.

## HN discussion (5 comments)

### [prajaybasu](<https://news.ycombinator.com/item?id=50648840>)

> I believe I have, working with Claude, Gemini and Astra, discovered a faster algorithm for extracting hexadecimal digits of π.
>
> https://github.com/prajaybasu/math

### [nickcw](<https://news.ycombinator.com/item?id=50640564>)

> 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 denominator, so only needs 1 division per term.
>
> It is the divisions which are slow so reducing the number of them speeds up the calculation. That plus another trick makes the calculation run 40% faster than the best known BBP formula.
>
> \> There’s a choice hiding in the last step of Bellard’s terse derivation.
>
> That made me laugh. It took me several days to figure out Bellard's terse derivation :-)

### [dh2022](<https://news.ycombinator.com/item?id=50644696>)

> The formula for calculating the % improvements is wrong.
>
> The correct formula is 100% - t_after / t_before.
>
> The formula in the article seems to be t_before / t_after - 100%. This is incorrect.
>
> For example if t_after is very small (meaning a very efficient calculation with a lot of improvement) this formula would indicate more than 100% improvement (and this is clearly incorrect)

---

## Cite

- Page: https://zeli.app/story/50638075
- Date: 2026-11-25
- Source: stylewarning.com (https://www.stylewarning.com/posts/faster-digit-extraction/)
- Hacker News: https://news.ycombinator.com/item?id=50638075

## Other languages

- zh: https://zeli.app/zh/story/50638075 · markdown: https://zeli.app/zh/story/50638075.md
- ja: https://zeli.app/ja/story/50638075 · markdown: https://zeli.app/ja/story/50638075.md
- ko: https://zeli.app/ko/story/50638075 · markdown: https://zeli.app/ko/story/50638075.md
- de: https://zeli.app/de/story/50638075 · markdown: https://zeli.app/de/story/50638075.md
- es: https://zeli.app/es/story/50638075 · markdown: https://zeli.app/es/story/50638075.md
- ru: https://zeli.app/ru/story/50638075 · markdown: https://zeli.app/ru/story/50638075.md
