BBP algorithm for calculating $\pi$ digits, sequentially

25 Views Asked by At

The wiki article https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula says $$ \pi = \sum_{k=0}^{\infty} \left[ \frac{1}{16^k} \left( \frac{120k^2 + 151k + 47}{512k^4 + 1024k^3 + 712k^2 + 194k + 15} \right) \right] $$ In trying to implement an algorithm for the actual computation, I found this: https://literateprograms.org/pi_with_the_bbp_formula__python_.html#sequential_generation where, in the final part, the author computes the fraction $$ \frac{120k^2 - 89k + 16}{512k^4 - 1024k^3 + 712k^2 - 206k + 21} $$ which is quite reminiscent of the one cited above, but not the same. A quick test shows that the first output digits are correct.

I really can't find ideas on the derivation of this second fraction from the original. Where does the second fraction come from?