---
title: Two-Term Machin-Like Formulas
url: https://www.emergentmind.com/topics/two-term-machin-like-formulas
type: topic
---

# Two-Term Machin-Like Formulas

Two-term Machin-like formulas are identities that represent $\pi/4$ as a sum of two arctangent terms, typically with rational arguments and, in a widely studied family, a dyadic coefficient on one term. A central form is
$$
\frac{\pi}{4}=2^{k-1}\arctan\left(\frac{1}{u_{1,k}}\right)+\arctan\left(\frac{1}{u_{2,k}}\right),\qquad k\in\mathbb{Z},\ k\ge 1,
$$
with $u_{1,k}$ chosen as an integer and $u_{2,k}$ obtained as a rational number determined by $u_{1,k}$ and $k$ [2107.01027]. Research on these formulas has focused on exact derivation from the arctangent addition law, nested-radical and purely rational constructions of the parameters, reduction of Lehmer’s measure, and high-precision evaluation strategies that avoid irrational numbers in the final computation [1704.02875, 1706.08835, 2004.11711]. Later work has extended the subject to classification results, continued-fraction refinements, and rational approximations with squared convergence [2302.00154, 2406.08510, 2601.10300].

## 1. General algebraic structure

The algebraic basis of a two-term Machin-like formula is the addition law
$$
\arctan x+\arctan y=\arctan\!\Bigl(\frac{x+y}{1-xy}\Bigr),
$$
together with the doubling identity
$$
2\,\arctan x=\arctan\!\Bigl(\frac{2x}{1-x^2}\Bigr).
$$
In the standard dyadic family, one sets
$$
x=\tan\!\bigl(2^{k-1}\arctan(1/u_1)\bigr)
$$
and then chooses $y$ so that
$$
\frac{x+y}{1-xy}=1.
$$
Solving gives
$$
y=\frac{1-x}{1+x},
$$
and therefore
$$
\frac1{u_{2,k}}=\frac{1-\tan(2^{k-1}\arctan(1/u_{1,k}))}{1+\tan(2^{k-1}\arctan(1/u_{1,k}))},
$$
which yields the required identity for $\pi/4$ [2107.01027].

An equivalent route uses complex exponentials. One shows
$$
\Bigl(\frac{u_1+i}{u_1-i}\Bigr)^{2^{k-1}}
=
\frac{1+i/u_{2,k}}{1-i/u_{2,k}},
$$
or, in a closely related formulation,
$$
\frac{\beta_2+i}{\beta_2-i}=i\cdot\Bigl(\frac{\beta_1-i}{\beta_1+i}\Bigr)^{2^{k-1}},
$$
from which the second parameter emerges as a rational number whenever the first one is rational [2107.01027, 1712.04414]. This complex representation is central in the literature because it converts the analytic condition that the arctangent sum equal $\pi/4$ into an explicit algebraic relation.

The general theory is not restricted to the dyadic coefficient $2^{k-1}$. A broader two-term setting considers
$$
a_0\arctan(u_0)+a_1\arctan(u_1)=\frac{\pi}{4},
$$
with $a_0,a_1\in\mathbb Z$ and $u_0,u_1\in\mathbb Q_{>0}$, $u_0>u_1$ [2601.10300]. This wider formulation supports later refinement procedures based on continued fractions, while the dyadic family remains the main computationally oriented branch of the subject.

## 2. Nested-radical parametrization of the first argument

A classical construction of the “large” integer in the dyadic family uses nested radicals. Defining
$$
a_0=0,\qquad a_k=\sqrt{2+a_{k-1}},\qquad k=1,2,3,\dots,
$$
one sets
$$
u_{1,k}=\Bigl\lfloor \frac{a_k}{\sqrt{2-a_{k-1}}}\Bigr\rfloor.
$$
This provides a closed-form choice of the first integer parameter [2107.01027]. Related work also allows the ceiling choice
$$
\beta_1=\Bigl\lceil \frac{a_k}{\sqrt{2-a_{k-1}}}\Bigr\rceil
$$
in the construction of a two-term identity [2108.07718].

The nested radicals are directly tied to classical trigonometric half-angle structure. In the notation $c_0=0$, $c_n=\sqrt{2+c_{n-1}}$, one has
$$
c_n=2\cos\!\Bigl(\frac{\pi}{2^{n+1}}\Bigr),
$$
and
$$
\frac{c_n}{\sqrt{2-c_{n-1}}}=\cot\!\Bigl(\frac{\pi}{2^{n+1}}\Bigr),
$$
which tends to infinity with $n$ [2509.25221]. This explains why the first argument in the arctangent becomes very small as $k$ increases.

The classical Machin formula appears as a small-$k$ instance of this scheme. The computation
$$
u_{1,3}=\Bigl\lfloor\frac{\sqrt{2+\sqrt2}}{\sqrt{2-\sqrt2}}\Bigr\rfloor=\lfloor 5.828\ldots\rfloor=5
$$
recovers
$$
\frac{\pi}{4}=4\,\arctan\!\Bigl(\frac15\Bigr)-\arctan\!\Bigl(\frac1{239}\Bigr)
$$
[2107.01027]. In this way the literature places Machin’s original identity inside a systematic infinite family indexed by $k$.

The nested-radical parametrization is compact, but it requires repeated square roots. Later papers therefore distinguish between the theoretical convenience of the closed form and the practical difficulty of carrying deep surd chains at large $k$ [2107.01027, 2004.11711].

## 3. Iterative determination of the second argument and surd-free updates

Once the first parameter is fixed, the second one can be computed by a short real iteration rather than by direct exponentiation of a complex rational. In one standard formulation, define
$$
\sigma_1=\Re\!\Bigl(\frac{u_1+i}{u_1-i}\Bigr),\qquad
\tau_1=\Im\!\Bigl(\frac{u_1+i}{u_1-i}\Bigr),
$$
and for $n=2,\dots,k$ iterate
$$
\sigma_n=\sigma_{n-1}^2-\tau_{n-1}^2,\qquad
\tau_n=2\,\sigma_{n-1}\tau_{n-1}.
$$
Then
$$
u_{2,k}=\frac{\sigma_k}{1-\tau_k}.
$$
This “$\sigma$-$\tau$ iteration” produces exactly the rational second parameter that makes the two-term identity valid [2107.01027].

Equivalent recurrences appear throughout the literature. With
$$
x_1=\frac{u_1^2-1}{u_1^2+1},\qquad y_1=\frac{2u_1}{u_1^2+1},
$$
one may iterate
$$
x_n=x_{n-1}^2-y_{n-1}^2,\qquad y_n=2x_{n-1}y_{n-1},
$$
and again obtain
$$
u_2=\frac{x_k}{1-y_k}
$$
[1706.08835]. The computational purpose is the same in each version: direct raising of $\bigl((u_1+i)/(u_1-i)\bigr)^{2^{k-1}}$ is avoided.

A further development replaces the nested-radical construction of the first parameter by a purely rational iteration. For large $k$, one may postulate
$$
u_{1,k+1}=\lfloor \phi(u_{1,k},k)\rfloor,
\qquad
\phi(u,k)=
\frac{1}{\,\tfrac1u+\tfrac1{2^k}(1-\tan(2^{k-1}/u))\,}.
$$
The tangent value is then computed by repeated doubling,
$$
f_1(x)=\frac{2x}{1-x^2},\qquad
f_n(x)=\frac{2f_{n-1}(x)}{1-f_{n-1}(x)^2},
$$
so that the update uses only rational operations and the real function $\tan(x)$ [2107.01027]. The stated computational observation is that in practice only $4$–$6$ nested calls suffice, no matter how large $k$ is.

Another iterative route begins with
$$
\gamma_k=\Bigl\lfloor \frac{c_k}{\sqrt{2-c_{k-1}}}\Bigr\rfloor,
\qquad
v_1=\gamma_k,\qquad
v_n=\frac12\Bigl(v_{n-1}-\frac1{v_{n-1}}\Bigr),\ n=2,\dots,k,
$$
and shows that
$$
2^{k-1}\arctan(1/\gamma_k)=\arctan(1/v_k).
$$
A second application of the addition law yields the compact identity
$$
\frac{\pi}{4}
=
\arctan\!\Bigl(\frac1{v_k}\Bigr)+
\arctan\!\Bigl(\frac{v_k-1}{v_k+1}\Bigr),
$$
or, equivalently,
$$
\frac{\pi}{4}
=
2^{k-1}\arctan(1/\gamma_k)+
\arctan\!\Bigl(\frac{v_k-1}{v_k+1}\Bigr)
$$
[2509.25221]. This suggests a structurally different, but still two-term, normalization of the same underlying half-angle mechanism.

## 4. Lehmer’s measure and convergence behavior

Lehmer introduced a measure for Machin-like formulas,
$$
\mu=\sum_{j=1}^{J}\frac{1}{\log_{10}|\beta_j|},
$$
to quantify the computational efficiency of
$$
\frac{\pi}{4}=\sum_{j=1}^{J}\alpha_j\arctan\!\frac1{\beta_j}
$$
[2004.11711]. In a coefficient-sensitive two-term normalization
$$
x_1\arctan(a_1/b_1)+x_2\arctan(a_2/b_2)=\frac{\pi}{4},
$$
the measure is written as
$$
\mu=
\frac{|x_1|}{\log_{10}(b_1/|a_1|)}+
\frac{|x_2|}{\log_{10}(b_2/|a_2|)}
$$
[2302.00154]. Across these formulations, the common interpretation is that smaller measure corresponds to faster convergence.

A landmark example in the computational branch takes $k=27$ and
$$
u_1=85\,445\,659.
$$
The resulting second parameter is a rational number whose numerator and denominator have $522\,185\,816$ and $522\,185\,807$ decimal digits, respectively, and the corresponding measure is reported as
$$
e\approx 0.245319.
$$
For this construction, each additional term in the arctangent series improves $\pi$ by about $16$ correct decimal digits, and the paper describes this as the smallest Lehmer measure ever reported for the Machin-like formulas for $\pi$ [1706.08835].

The later theoretical picture is broader. Gasull, Luca, and Varona proved that in the two-term case one can make $\mu\to0$ through a construction based on convergents to $\pi$ and a rational-function mechanism they call the “Machin’s formulas machine” [2302.00154]. This does not negate the earlier computational record; rather, it shows that the existence theory allows arbitrarily small Lehmer measure, while explicit constructions with practical computational behavior must still address the size and handling of the rational parameters.

The relation between convergence and argument size is also visible in the elementary Maclaurin estimate
$$
\arctan(x)=x+O(x^3)
$$
for small $x$. Since two-term Machin-like formulas are designed so that both reciprocal arguments are small, increasing $k$ can greatly accelerate convergence [1704.02875]. The computational challenge is that the second rational parameter often grows to enormous size, so asymptotic speed in the series variable does not automatically translate into low wall-clock cost.

## 5. Numerical evaluation and rational approximations

A major computational issue is that the second argument may be tiny while its rational representation is huge. Direct evaluation of $\arctan(1/\beta_2)$ by a power series can therefore be slowed by large intermediate numerators and denominators [1712.04414]. To address this, the literature applies Newton–Raphson to
$$
\tan(y)=\frac1{\beta_2},
$$
with update
$$
y_{n+1}=y_n-\frac{\tan(y_n)-x}{\sec^2(y_n)}
      =y_n-\bigl(\tan(y_n)-x\bigr)\cos^2(y_n),
\qquad x=\frac1{\beta_2}.
$$
This gives quadratic convergence: each iteration roughly doubles the number of correct digits [1712.04414].

A concrete example takes $k=6$ and $\beta_1=40$. Using the nested-radical prescription, one obtains an explicit rational $\beta_2$, starts from a coarse value of $\pi$, and then refines $y=\arctan(1/\beta_2)$ by Newton–Raphson. The reported sequence improves from about $5$ correct digits of $\pi$ to $10$ and then to about $24$ digits in successive iterations [1712.04414]. Related work argues that this evaluation strategy establishes the unconditional applicability of Lehmer’s measure in the two-term rational case, because the algorithm never requires exponentiating the giant rational $\beta_2$; the only use of $1/\beta_2$ is a single subtraction inside a Newton–Raphson step [2004.11711].

A separate line of work replaces both surds and trigonometric function calls by a rational approximation built from the binary expansion of $1/\pi$. In that setting,
$$
\frac{\pi}{4}
=
2^{k-1}\arctan\!\Bigl(\frac1{\alpha_k}\Bigr)+
\arctan\!\Bigl(\frac1{\beta_k}\Bigr),
$$
with $\alpha_k,\beta_k\in\mathbb Q$, is approximated by
$$
\frac{\pi}{4}\approx
\frac1{\alpha_k}+\frac12\Bigl(1-\eta_{k-1}(1/\alpha_k)\Bigr),
$$
where
$$
\eta_1(x)=\frac{2x}{1-x^2},\qquad
\eta_n(x)=\frac{2\eta_{n-1}(x)}{1-\eta_{n-1}(x)^2}.
$$
The resulting error satisfies
$$
E_k=O(2^{-2k}),
$$
and the paper describes this as squared convergence in computing digits of $\pi$ without any trigonometric functions and surd numbers [2406.08510]. This suggests that two-term Machin-like structure can function not only as an exact identity but also as the basis of purely rational approximation algorithms.

## 6. Refinements, classifications, and later theoretical developments

The two-term theory now includes both classification results and transformation procedures. In the 2-integer setting, Gasull, Luca, and Varona prove that the only solutions of
$$
x_1\arctan z_1+x_2\arctan z_2=\frac{\pi}{4},
$$
with $z_1<z_2\in(0,1)$ of the form $z=2^a/b$ or $b/2^a$, consist of ten sporadic cases plus two infinite $1$-parameter families [2302.00154]. The two families are
$$
\frac{\pi}{4}
=
\arctan\!\frac{1}{2^{a+1}+1}
+
\arctan\!\frac{2^a}{2^a+1},
$$
and
$$
\frac{\pi}{4}
=
\arctan\!\frac{1}{2^{a+1}-1}
+
\arctan\!\frac{2^a-1}{2^a}.
$$
This establishes a rare complete classification statement inside the two-term landscape.

The same paper also formulates the “Machin’s formulas machine.” For suitable rational functions $R_j(n,x)$ satisfying
$$
\frac{d}{dx}\arctan(R_j(n,x))=\frac{n}{1+x^2},
$$
one obtains infinitely many two-term formulas by choosing parameters so that the resulting arctangent arguments stay inside $(-1,1)$ [2302.00154]. In the special case $N=2$, the authors state that the method is quite useful, recovers most known formulas, gives some new ones, and allows one to prove in an easy way that there are two terms Machin formulas with Lehmer measure as small as desired.

A different extension is the refinement process for a general two-term formula
$$
a_0\arctan(u_0)+a_1\arctan(u_1)=\frac{\pi}{4}.
$$
Setting
$$
\alpha=\frac{\arctan(u_0)}{\arctan(u_1)}>1,
$$
forming the continued fraction $\alpha=[q_0;q_1,q_2,\dots]$, and defining a decreasing sequence of positive rationals by
$$
\arctan(u_k)=q_k\,\arctan(u_{k+1})+\arctan(u_{k+2}),
$$
one obtains, recursively,
$$
a_{-n-1}=q_n a_{-n}+a_{-n+1}
$$
and hence a whole sequence of two-term identities
$$
a_{-n}\arctan(u_n)+a_{-n+1}\arctan(u_{n+1})=\frac{\pi}{4},
\qquad n=0,1,2,\dots
$$
[2601.10300]. Closed forms in terms of the convergents $N_n/D_n$ of $\alpha$ are given by
$$
a_{-n-1}=a_0N_n+a_1D_n,
$$
and
$$
\arctan(u_n)=(-1)^n\Bigl(D_{n-2}\arctan(u_0)-N_{n-2}\arctan(u_1)\Bigr).
$$
The associated rational sequence
$$
a_{-n}u_n+a_{-n+1}u_{n+1}
$$
converges to $\pi/4$ with geometric decay, and the method is illustrated from Euler’s formula
$$
\arctan(1/2)+\arctan(1/3)=\frac{\pi}{4}
$$
[2601.10300].

These later developments show that two-term Machin-like formulas are not a single isolated family but a broad class of exact identities and approximation schemes. The subject now spans nested radicals, rational recurrences, Newton–Raphson evaluation, continued-fraction refinements, and structural classification, while preserving the defining feature that $\pi/4$ is represented by only two arctangent contributions.

Source: https://www.emergentmind.com/topics/two-term-machin-like-formulas