Pi (π) Calculator via Machin-like Two-Term Arctangent Series

Pi (π) Calculator via Machin-like Two-Term Arctangent Series

Emerging AI Skill PRO

Enter Calculation

Formula

π=4[4arctan⁡15−arctan⁡1239]where{Series=Machin 1706arctan⁡x≈∑k=0N−1(−1)kx2k+12k+1N≤Max iterationsstop when |tk|<12×10−(Digits+2)\begin{gathered} \pi = 4\left[\,4\arctan\tfrac{1}{5} \; - \; \arctan\tfrac{1}{239}\,\right] \\[1.5em] \text{where}\quad \left\{ \begin{aligned} \text{Series} &= \text{Machin 1706} \\ \arctan x &\approx \sum_{k=0}^{N-1} \frac{(-1)^{k}\,x^{2k+1}}{2k+1} \\ N &\le \text{Max iterations} \\ \text{stop when } |t_k| &< \tfrac{1}{2}\times 10^{-\left(\text{Digits}+2\right)} \end{aligned} \right. \end{gathered}
Usage stats

Advertisement

Results

Computed value of Pi
3.141592653663433
Arctangent formula: Machin 1706
True Pi (Math.PI) 3.141592653589793
Terms used 16
Absolute error vs. true Pi 7.363976E-11

Report an error on this page

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.

Gregory arctangent series shown as shrinking alternating bars converging to a value
Each arctangent is evaluated with the alternating Gregory series whose terms shrink rapidly.

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\).

Advertisement

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.

Diagram showing pi as a combination of two scaled arctangent angles built from right triangles
A Machin-like formula expresses π as a weighted sum of two arctangent terms.

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.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators