What this calculator does
This tool computes the mathematical constant Pi by evaluating one of several historic "Machin-like" two-term arctangent formulas. Each formula writes Pi/4 as a weighted sum of two arctangents of small rational numbers, and each arctangent is expanded with the classic Gregory/Leibniz power series. Because the arguments are small, the series converges quickly and only a handful of terms are needed for full double-precision accuracy.
How to use it
Pick a famous formula from the dropdown — Machin (1706), Hermann (1706), Euler (1738), Euler & Vega (1755), or Hutton (1776). Choose how many significant digits you want and a cap on the number of series terms (Max iterations). The calculator returns the computed value of Pi, the number of terms it summed before the next term fell below the tolerance, and the absolute error compared with the true value of Pi.
Note: this rebuilt version uses IEEE double-precision arithmetic, which is faithful to about 15–16 significant digits. Settings above that are capped at 15 digits; arbitrary-precision arithmetic would be required for the 22–50 digit ranges of the original tool.
The formula explained
The general identity is $$\pi = 4\left(c_1\,\arctan\frac{p_1}{q_1} + c_2\,\arctan\frac{p_2}{q_2}\right)$$ The Gregory series \(\arctan(x) = x - x^3/3 + x^5/5 - x^7/7 + \dots\) is summed term by term until a term drops below the tolerance \(0.5\times 10^{-(\text{digits}+2)}\). Smaller arguments converge faster: Machin's \(1/5\) and \(1/239\) reach high accuracy in far fewer terms than Euler's \(1/2\) and \(1/3\).
Worked example (Machin 1706)
With arg1 = 1/5 and c1 = 4, \(\arctan(0.2) \approx 0.19739555985\). With arg2 = 1/239 and c2 = −1, \(\arctan(1/239) \approx 0.00418407600\). Then $$\pi/4 = 4\cdot 0.19739555985 - 0.00418407600 = 0.78539816339$$ so $$\pi = 4\cdot 0.78539816339 = 3.14159265359$$ matching the true value.
FAQ
Why isn't the Leibniz series (arctan 1) an option? Because \(\arctan(1) = \pi/4\) converges agonizingly slowly — thousands of terms yield only a few correct digits — so it is mentioned for history but not offered as a fast formula.
Why does Machin use fewer terms than Euler? Its arguments (\(1/5\), \(1/239\)) are smaller, and the Gregory series converges faster for smaller \(|x|\).
Can I get 40 digits of Pi here? Not with double precision; the result is reliable to roughly 15 digits. Higher precision needs big-decimal arithmetic.