This is just a demo I made for nickliu. It uses the Machin formula. You can not change the precision. https://en.wikipedia.org/wiki/Machin-like_formula pi/4 = 4 arctan 1/5 - arctan 1/239 My scratch implementation here calculates pi to four correct places in 0.000035 sec on my computer.
Thanks for the background nickliu.