Ask HN: Is there a math formula that can give me nth pie digit?
I want to make a function that gives me nth pie digit without calculating it from 1st digit.
So getNthPie(2) -> 4
and getNthPie(1000000) -> 4
So getNthPie(2) -> 4
and getNthPie(1000000) -> 4
7 comments
[ 3.3 ms ] story [ 20.0 ms ] threadUpdate: only in hex: https://en.m.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80...
https://mathworld.wolfram.com/Digit-ExtractionAlgorithm.html
https://arxiv.org/abs/2201.12601
I first wrote that I thought this was asymptotically much faster than computing the intermediate digits, but somewhat slow because it requires computing Bernoulli numbers as one input. But in Plouffe's PDF, he says that actually the convergence is very slow and you would do significantly better computing the intermediate digits with mainstream pi-calculating methods. For instance, he states that
> The current record for Bernoulli numbers is 100 million. So, we can calculate the 100,000,000th decimal of π with this process. Note that the calculation of Bernoulli numbers can be done in several ways, one of which requires knowing π with good precision.
The BBP formula represents pi directly as a sum of increasing powers of 1/16, and provides a given hex digit in constant time. Such a formula has not been found for decimal digits