Preprint
Article

This version is not peer-reviewed.

Application of a New Iterative Formula for Computing π and Nested Radicals with Roots of 2

A peer-reviewed article of this preprint also exists.

Submitted:

24 September 2025

Posted:

25 September 2025

You are already at the latest version

Abstract
In this work, we obtain an iterative formula that can be used for computing digits of π and nested radicals of kind \( c_n/\sqrt{2 - c_{n - 1}} \), where c0=0 and \( c_n = \sqrt{2 + c_{n - 1}} \). We also show how with help of this iterative formula the two-term Machin-like formulas for π can be generated and approximated. Some examples with Mathematica codes are presented.
Keywords: 
;  ;  ;  

1. Introduction

Throughout many centuries computing digits of π remained a big challenge [1,2,3,4]. However, in 1876 English astronomer and mathematician John Machin found an efficient method to resolve this problem. Historically, he was the first to calculate over 100 digits of π . In his approach, John Machin discovered and then used the following remarkable formula [1,2,3,4]
π 4 = 4 arctan 1 5 arctan 1 29 .
Nowadays, the identities of kind
π 4 = j = 1 J A j arctan 1 B j , A j , B j Q
are named after him as the Machin-like formulas for π .
The arctangent terms in the Machin-like formulas for π can be computed by using the Maclaurin expansion series
arctan ( x ) = x x 3 3 ! + x 5 5 ! x 7 7 ! + = n = 0 x 2 k 1 ( 2 k 1 ) ! , x 1 .
Since according to this equation, we get
arctan ( x ) = x + O ( x 3 ) ,
the convergence of the Machin-like formulas (2) for π is always better when the values B j are larger by absolute value.
To estimate efficiency of the Machin-like formulas for π , Lehmer introduced a measure, defined as [5,6,7]
μ = j = 1 J 1 log 10 B j .
According to this formula, the smaller measure indicates the higher efficiency of the Machin-like formula π . Lehmer’s measure is smaller at larger absolute values of B j and smaller number of the summation terms J.
Generally, we should imply that Lehmer’s measure is valid only if all coefficients B j are integers. Otherwise if B j Z , its fractional parts
B j = B j B j
may cause further computational complexities requiring more usage of the computer memory and extending considerably a run-time in computing digits of π [7]. As the fractional part is not desirable in computation of the digits of π , it may be more preferable to apply the Machin-like formulas where all coefficients B j are integers.
The Machin-like formulas (2) for π can be validated by using the following relation
j = 1 J B j + i A j ( 1 + i ) .
The right side of this relation implies that the real part of the product must be equal to its imaginary part as follows
j = 1 J B j + i A j = j = 1 J B j + i A j .
For example, the original Machin formula (1) for π can be readily validated by applying this relation
( 5 + i ) 4 ( 259 + i ) 1 = 2 ( 1 + i )
since the real and imaginary parts of the product are equal to the same number 2.
In our previous publication [8], we proposed a method for deriving the two-term Machin-like formula for π in form
π 4 = 2 k 1 arctan 1 α + arctan 1 β ,
where α is an integer (see [9] for available values of α )
α = c k 2 c k 1
that can be computed by using the nested radicals such that
c 0 = 0 , c k = 2 + c k 1
and
β = 2 ( α + i ) / ( α i ) 2 k 1 i i .
Recently, Gasull et al. proposed an alternative method to obtain the two-term Machin-like formula for π of kind (5). In their publication, they suggested an iterative method based on R j ( n , x ) functions that can be defined as [7]
R j ( n , x ) = tan ( n σ + j π / 4 ) , x = tan ( σ ) , n , j N .
Application of formula (6) for determination of the coefficient β is not optimal. In particular, as integer k increases the exponent 2 k 1 in the denominator blows up very rapidly. As a consequence, this drastically delays computation. To resolve this problem, we proposed a two-step iteration procedure [8] that will be discussed in the next section. However, this iteration involves squaring that doubles the number of digits at each consecutive cycle of two-step iteration. Although as compared to equation (6) this iterative procedure is more efficient, it still remains computationally costly at larger values of k.
Motivated by recent publications [10,11,12,13,14,15,16], we propose a more efficient approach in determination of the coefficient β in equation (6). Furthermore, with these results we show how the constant π and nested radicals consisting of square roots of 2 can be obtained. Some numerical results with Mathematica codes are provided. To the best of our knowledge, this approach is new and has never been reported in scientific literature.

2. Preliminaries

As it has been mentioned above, equation (6) should be avoided for computation of the constant β at k 1 . The following theorem shows how else the constant β can be calculated.
Theorem 1. 
There is a formula such that
β = κ k 1 λ k ,
where
κ n = κ n 1 2 λ n 1 2 λ n = 2 κ n 1 2 λ n 1 2 n = { 2 , 3 , 4 , k } ,
with initial values
κ 1 = α 2 1 α 2 + 1
and
λ 1 = 2 α 2 α 2 + 1 .
Proof. 
From induction it follows that
κ 1 + i λ 1 2 k 1 = κ 1 + i λ 1 2 2 2 k 1 powers of 2 = κ 2 + i λ 2 2 2 2 k 2 powers of 2 = κ 3 + i λ 3 2 2 2 k 3 powers of 2 = κ n + i λ n 2 2 2 k n powers of 2 = κ k 2 + i λ k 2 2 2 = κ k 1 + i λ k 1 2 = κ k + i λ k ,
Therefore, from equations (6) and (9), we obtain
β = 2 κ k + i λ k i i = 2 κ k κ k 2 + ( λ k 1 ) 2 + i 2 ( 1 λ k ) κ k 2 + ( λ k 1 ) 2 1 .
Since β is a real number, the imaginary part of the equation above must be equal to zero. Consequently, we have
2 ( 1 λ k ) κ k 2 + ( λ k 1 ) 2 1 = 0
or
2 ( 1 λ k ) = κ k 2 + ( λ k 1 ) 2
or
κ k 2 = 2 ( 1 λ k ) ( λ k 1 ) 2 .
Substituting equation (11) into the real part of equation (10), we obtain equation (7). This completes the proof.    □
In our earlier publication [17], we show how to generate efficiently the multi-term Machin-like formulas for π by using the following equation-template
π 4 = 2 k 1 arctan 1 γ k + m = 1 M arctan 1 θ m , k + arctan 1 θ M + 1 , k ,
where
θ m , k = 1 + θ m 1 , k θ m 1 , k θ m 1 , k θ m 1 , k , m 2 .
In the formula (12), we imply that M 0 such that at M = 0 the sum
m = 1 M arctan 1 θ m , k
is equal to zero. Consequently, when M = 0 the equation (12) is reduced to
π 4 = 2 k 1 arctan 1 γ k + arctan 1 θ 1 , k ,
where γ k = α and θ 1 , k = β according to equation (5) above. In fact, the equation (12) can be obtained from equation (5) together with the following identity [17]
arctan 1 z = arctan 1 z + arctan z z 1 + z z , z [ 0 , 1 ) .
Consider how the two well-known Machin-like formulas for π can be derived by using equation (12). At k = 2 and M = 0 equation (12) results in
π 4 = 2 arctan 1 2 arctan 1 7 .
This equation is commonly known as the Hermann’s formula for π [18]. At k = 2 and M = 0 equation (12) leads to the original Machin formula (1) for π .
Application of the equation (12) may also be a useful technique to transform the arctangent term with the quotient θ 1 , k = β into sum of arctangents with reciprocal integers. For example, at k = 4 we get
γ 4 = c 4 2 c 3 = 2 + 2 + 2 + 2 2 2 + 2 + 2 = 10 .
Consequently, applying two-step iteration (8) we can find that
θ 1 , 4 = 147153121 1758719 .
Substituting these values into equation (12), results in
π 4 = 8 arctan 1 10 arctan 1758719 147153121 .
As it has been mentioned above, it is desirable to apply reciprocal integers rather than quotients. The equation (12) can be used to transform the quotients into reciprocal integers. For example, at k = 4 and M = 1 from equation (12) it follows that
π 4 = 8 arctan 1 10 arctan 1 84 arctan 579275 12362620883 .
At k = 4 and M = 2 equation (12) gives
π 4 = 8 arctan 1 10 arctan 1 84 arctan 1 21342 arctan 266167 263843055464261 .
Incrementing the integer M over and over again, at k = 4 and M = 5 equation (12) finally yields the 7-term Machin-like formula
π 4 = 8 arctan 1 10 arctan 1 84 arctan 1 21342 arctan 1 991268848 arctan 1 193018008592515208050 arctan 1 197967899896401851763240424238758988350338 arctan 1 Ω ,
Ω = 11757386816817535293027775284419412676799191500853701 8836932014293678271636885792397 ,
where all arctangent arguments are reciprocal integers.
As we can see, the Hermann’s (14), Machin’s (1) and the generated (16) formulas belong to the same generic group as all of them can be derived by using the same equation-template (12).
The following Mathematica code validates the equation (16).
(* Define long string *)
longStr = StringJoin["11757386816817535293027775284419412676",
    "7991915008537018836932014293678271636885792397"];
(* Computing the coefficient *)
coeff = (10 + I)^8*(84 + I)^-1*(21342 + I)^-1*(991268848 + I)^-1*
    (193018008592515208050+I)^-1*
    (197967899896401851763240424238758988350338 + I)^-1*
            (FromDigits[longStr]+I)^-1;
Print[Re[coeff] == Im[coeff]];
by returning the output True.
Once all quotients are transformed into reciprocal integers, we can compute the digits of π by using the Maclaurin series expansion (3) of the arctangent function. However, our empirical results show that the following two expansion series
arctan ( x ) = n = 0 2 2 n ( n ! ) 2 ( 2 n + 1 ) ! x 2 n + 1 ( 1 + x 2 ) n + 1
and
arctan ( x ) = 2 n = 1 1 2 n 1 g n ( x ) g n 2 ( x ) + h n 2 ( x ) ,
where
g 1 ( x ) = 2 / x , h 1 ( x ) = 1 ,
g n ( x ) = g n 1 ( x ) ( 1 4 / x 2 ) + 4 h n 1 ( x ) / x ,
h n ( x ) = h n 1 ( x ) ( 1 4 / x 2 ) 4 g n 1 ( x ) / x ,
can be used more efficiently for computing digits of π due to more rapid convergence.
Equation (17) is known as Euler’s series expansion. It is interesting to note that this series expansion can be derived from the following integral [19]
arctan ( x ) = 0 π / 2 x sin u 1 + x 2 1 1 x 2 sin 2 u 1 + x 2 d u .
Equation (18) can be derived by substituting
f ( x , t ) = x 2 1 1 + i x t + 1 1 i x t
into the identity
0 1 f ( x , t ) d t = 2 m = 1 M n = 0 1 ( 2 M ) 2 n + 1 ( 2 n + 1 ) ! 2 n t 2 n f ( x , t ) t = m 1 / 2 M
that we proposed and used earlier (see [20] and literature therein for more details). Computational test we performed shows that the arctangent series expansion (18) is significantly faster in convergence than the arctangent series expansion (17).
At k = 6 with help of the two-step iteration (8), we obtain
θ 1 , 6 = 2634699316100146880926635665506082395762836079845121 38035138859000075702655846657186322249216830232319 .
Consequently, the two-term Machin-like formula for π becomes
π 4 = 32 arctan 1 40 arctan 38035138859000075702655846657186322249216830232319 2634699316100146880926635665506082395762836079845121 .
As we can see, this equation contains a quotient with large number of digits in numerator and denominator. We may attempt to reduce the number of digits by approximation. Unfortunately, the two-step iteration (8) is not efficient in approximating θ 1 , k . Any our attempt to approximate θ 1 , k by two-step iteration (8) either do not provide a desired accuracy or completely diverge from the value θ 1 , k . This makes approximation inefficient and unpredictable especially at lager values of the integer k.
Moreover, the number of digits rapidly grows with increasing k. For example, at k = 27 and M = 0 equation (12) results in
π 4 = 2 27 1 arctan 1 γ 27 + arctan 1 θ 1 , 27 = 67108864 arctan 1 85445659 arctan 9732933578 4975692799 2368557598 9903554561 ,
where argument in the second arctangent function contains 522 , 185 , 807 digits in the numerator and 522 , 185 , 816 digits in the denominator. In the recent publication, Gasull et al. showed that at k = 31 number of digits in the numerator and denominator in the two-term Machin-like formula for π of kind (5) are 9 , 647 , 887 , 023 and 9 , 647 , 887 , 033 , respectively (see Table 2 in [7]). Consequently, the two-step iteration (8) is appeared to be impractical for approximating the constants θ 1 , k .
This problem can be effectively resolved by using a new method of iteration that will be shown in the next section.

3. An Iterative Formula to Compute π

A problem that appears with two-step iteration (8) is a rapidly growing number of digits. In particular, the number of digits in κ n and λ n doubles at each consecutive increment of the index n. This may also restrict the application of the two-step iteration (8). The following theorem shows a new iteration technique as an alternative to the double-step iteration (8).
Theorem 2. 
There is a two-term Machin-like formula
π 4 = arctan 1 u + arctan u 1 u + 1 .
Proof. 
The proof is straightforward and immediately follows from the following identity
arctan ( x ) + arctan ( y ) = arctan x + y 1 x y .
Specifically, assuming
x = 1 u
and
y = u 1 u + 1 ,
according to identity (19) we have
1 / u + ( u 1 ) / ( u + 1 ) 1 1 / u ( u 1 ) / ( u + 1 ) = 1 .
This completes the proof since
arctan ( 1 ) = π 4 .
   □
Consider now the next theorem.
Theorem 3. 
There is a relation
2 k 1 arctan 1 γ k = arctan 1 v k ,
where
v n = 1 2 v n 1 1 v n 1 , n = { 2 , 3 , k }
such that
v 1 = γ k .
Proof. 
Since
2 0 arctan 1 γ 1 = arctan 1 v 1 ,
it follows that
2 1 arctan 1 γ 2 = arctan 1 v 2 ,
where
1 v 2 = 2 / v 1 1 1 / v 1 2 .
Similarly, at k = 3 we get
2 2 arctan 1 γ 3 = arctan 1 v 3 ,
where
1 v 3 = 2 / v 2 1 1 / v 2 2 .
Therefore, by induction for an arbitrary integer k we can write
2 k 1 arctan 1 γ k = arctan 1 v k ,
where
1 v k = 2 / v k 1 1 1 / v k 1 2 .
The equation above can be rewritten as
v k = 1 2 v k 1 1 v k 1 .
and this proves the theorem.    □
Thus, from this and above theorems it follows that
π 4 = 2 k 1 arctan 1 v 1 + arctan v k 1 v k + 1 .
where
v k 1 v k + 1 = 1 θ 1 .
The iterative formula (20) and equation (21) are our main results. Despite simplicity, their significance can be demonstrated in computing digits of π and nested radicals consisting of square roots of 2.

4. Approximation Methodologies

4.1. A Rational Approximation of π

Recently, we have reported a rational approximation for π by approximating the two-term Machin-like formula (13) [21]. Here we show how a rational approximation for π can be constructed by using the equation (21) based on iterative formula (20).
Consider the following theorem.
Theorem 4. 
There is a limit such that
lim k c k = 2 .
Proof. 
This is Ramanujan’s nested radical. Since
c k = 2 + 2 + 2 + + 2 k square roots = 2 + c k 1 ,
we can write
lim k c k = lim k 2 + c k 1 = lim k 2 + c k .
Let
z = lim k c k .
Then, solving the equation
z = 2 + z
or
z 2 z 2 = 0 ,
we get two solutions z 1 = 1 and z 2 = 2 . Since the sequence
{ c 0 , c 1 , c 2 , c 3 , } = 0 , 2 , 2 + 2 , 2 + 2 + 2 ,
monotonically increases and positive at any c n except c 0 = 0 , we have to exclude the negative solution. Consequently, the theorem is proved.    □
From the theorem 4 we can make a conclusion that
lim k 2 c k = 0
since due to relation
lim k c k = 2
leading to
lim k 2 c k = 2 lim k c k = 0
the limit (22) follows.
Next, will we try to find a rational approximation for computing digits of π . This can be done by using equation (21). In order to approximate it, we need to consider two lemmas below.
Lemma 1. 
There is a limit such that
π 4 = lim k 2 k 1 arctan 1 γ k .
Proof. 
By definition
c k 2 c k 1 1 < γ k < c k 2 c k 1 .
Since
lim k c k = 2
while
lim k 2 c k 1 = 0
we can infer that
lim k c k 2 c k 1 = .
Therefore, we can write
lim k γ k 2 c k 1 / c k = 1
from which it follows that
lim k arctan 2 c k 1 c k = lim k arctan 1 γ k
and proof of this lemma follows since [22]
lim k 2 k 1 arctan 2 c k 1 c k = π 4 .
   □
Lemma 2. 
There is a limit
π 4 = lim k 2 k 1 γ k + 1 θ 1 , k = lim k 2 k 1 v 1 + v k 1 v k + 1 .
Proof. 
The proof follows immediately from the lemma 1 and due to equation (21).    □
The importance of the lemma 2 can be seen by comparing the accuracy of two approximations
π 4 2 k 1 γ k = 2 k 1 v 1
and
π 4 2 k 1 γ k + 1 θ 1 , k = 2 k 1 v 1 + v k 1 v k + 1 .
Since v k is very close to unity, the double-term rational approximation (25) can be simplified as
π 4 2 k 1 v 1 + v k 1 2 .
Mathematica code below shows how number of digits of π can be computed by using a single- and double-term rational approximations (24) and (26), respectively.
Clear[k, c, flNum, accNum, v1, vk];
(* Integer k *)
k = 3000;
(* Use if needed: $RecursionLimit = 100000; *)
$RecursionLimit = 50000;
c[0] := c[0] = 0;
c[n_] := c[n] = SetAccuracy[Sqrt[2 + c[n - 1]], k];
(* Floor number *)
flNum = Floor[c[k]/Sqrt[2 - c[k - 1]]];
(* Accuracy number *)
accNum = Length[RealDigits[flNum][[1]]];
(* Coefficient v_1 *)
v1 = SetAccuracy[flNum, 2*accNum];
Print["At k = ", k, " number of digits of \[Pi] with single term: ",
  MantissaExponent[\[Pi] - 4 (2^(k - 1)/v1)][[2]] // Abs];
(* Compute coefficient v_k *)
vk = v1;
Do[vk = 1/2 (vk - 1/vk), k - 1];
Print["At k = ", k, " number of digits of \[Pi] with two terms: ",
    MantissaExponent[\[Pi] - 4 (2^(k - 1)/v1
    + (vk - 1)/2)][[2]] //Abs];
This code generates the following output:
At k = 3000 number of digits of À with single term: 902
At k = 3000 number of digits of À with two terms: 1805
As we can see from this example, once we know the value of the constant v k , at k = 3000 the number of digits of π is doubled from 902 to 1805.

4.2. An Approximation of π with Cubic Convergence

Now we show how to obtain a formula for π with cubic convergence. Consider the following theorem.
Theorem 5. 
The two-term Machin-like formula (13) for π can be represented in trigonometric form as
π 4 = arctan 2 k 1 γ k + arctan 1 sin 2 k 1 arctan 2 γ k γ k 2 1 cos 2 k 1 arctan 2 γ k γ k 2 1
Proof. 
Applying de Moivre’s theorem we can write
( κ 1 + i λ 1 ) 2 k 1 = κ 1 2 + i λ 1 2 2 k 2 cos 2 k 1 Arg ( κ 1 + i λ 1 ) + i sin 2 k 1 Arg ( κ 1 + i λ 1 )
Substituting equation above into equation (10) and taking into consideration that θ 1 , k = β we get
θ 1 , k = cos 2 k 1 Arg ( κ 1 + i λ 1 ) 1 sin 2 k 1 Arg ( κ 1 + i λ 1 ) .
Since
Arg ( x + i y ) = arctan y x , x > 0 ,
it follows that
Arg ( κ 1 + i λ 1 ) = arctan 2 γ k γ k 2 1 , x > 0 .
Consequently, the equation (10) can be represented as
θ 1 , k = cos 2 k 1 arctan 2 γ k γ k 2 1 1 sin 2 k 1 arctan 2 γ k γ k 2 1
and this completes the proof.    □
We may attempt to approximate the coefficient θ 1 , k . Since
2 γ k γ k 2 1 2 γ k
with increasing k, the equation (27) can be approximated as
θ 1 , k cos 2 k 1 arctan 2 γ k 1 sin 2 k 1 arctan 2 γ k .
Since
arctan ( x ) x , | x | 1 ,
the approximation above can be further simplified as
θ 1 , k cos 2 k γ k 1 sin 2 k γ k .
Using the following trigonometric identities
cos ( x ) = 2 tan ( x / 2 ) 1 + tan 2 ( x / 2 )
and
sin ( x ) = 1 tan 2 ( x / 2 ) 1 + tan 2 ( x / 2 )
the equation (28) can be expressed as
θ 1 , k 1 + tan 2 2 k 1 / γ k 1 tan 2 k 1 / γ k .
This leads to
1 θ 1 , k 1 tan 2 k 1 / γ k 1 + tan 2 2 k 1 / γ k .
Since
tan 2 2 k 1 / γ k
converges faster to 1 than
tan 2 k 1 / γ k ,
we can simplify approximation (29) as
1 θ 1 , k 1 2 1 tan 2 k 1 / γ k .
Substituting approximation (30) into equation (13), we can approximate the two-term Machin-like formula (1) for π as follows
π 4 arctan 1 γ k + arctan 1 2 1 tan 2 k 1 γ k .
Consequently, from the lemma 2 we have
π 4 2 k 1 γ k + 1 2 1 tan 2 k 1 γ k .
Consider now the following limit
lim x π / 4 2 sin 2 ( x ) tan ( x ) = 1 .
Since numerator of this limit is very close to its denominator near vicinity of π / 4 , we may replace tangent function in approximation (31) with twice of square of sine function. This leads to
π 4 2 k 1 γ k + 1 2 1 2 sin 2 2 k 1 γ k
or
π 4 2 k 2 γ k + 1 2 cos 2 k γ k
or
π 2 2 k γ k + cos 2 k γ k .
Equation (32) provides a hint for computation of π . Using an heuristic assumption by change of the variable such that
2 k γ k a 1 , k 1 ,
we may attempt to compute π by using the following iteration
a n = a n 1 + cos ( a n 1 )
resulting in
lim n a n = π 2 .
The following is a Mathematica code for computing digits of π with help of the iterative formula (33).
Clear[a, accNum, n];
(* Initial accuracy number *)
accNum = 10;
(* Initial value of À/2 *)
a = SetAccuracy[3.145926/2, accNum];
Print["--------------------------------------"];
Print["Iteration n", "  |  ", "Number of digits of À"];
Print["--------------------------------------"];
(* Iteration *)
For[n = 1, n <= 8, a = SetAccuracy[a + Cos[a], accNum];
    Print[n, "            |  ", MantissaExponent[Pi
        - 2*a][[2]]//Abs]; accNum = 5*accNum; n++];
Print["--------------------------------------"];
The output of this code:
--------------------------------------
Iteration n | Number of digits of À
--------------------------------------
1           | 8
2           | 26
3           | 76
4           | 232
5           | 698
6           | 2095
7           | 6288
8           | 18868
--------------------------------------
shows that the iterative formula (33) provides cubic convergence since number of digits of π increases by a factor of 3 after each iteration.

4.3. A Numerical Solution for the Nested Radicals with Roots of 2

As we can see, approximation (26) doubles the number of digits of π . However, this approach can be used not only for computing digits of π . It can also be used to compute nested radical consisting of square roots of 2. In particular, by using iterative formula (20) we can compute the nested radical with roots of 2 as follows
v k v k n 2 c n c n + 1 .
Mathematica code below shows how to generate digits of the nested radicals with roots of 2 at n = 3
v k v k 3 2 c 3 c 4 = 2 2 + 2 + 2 2 + 2 + 2 + 2 .
Clear[k, c, flNum, accNum, v]
(*Assign value of k*)
k = 5000;
(* Increase if needed: $RecursionLimit = 100000; *)
$RecursionLimit = 50000;
(* Define nested radicals *)
c[0] := c[0] = 0;
c[n_] := c[n] = SetAccuracy[Sqrt[2 + c[n - 1]], k];
(* Compute floor number *)
flNum = Floor[c[k]/Sqrt[2 - c[k - 1]]];
(*Set accuracy with accuracy number*)
accNum = Length[RealDigits[flNum][[1]]];
(*Compute v_k*)
v[1] := v[1] = SetAccuracy[Floor[flNum], accNum];
v[n_] := v[n] = 1/2 (v[n - 1] - 1/v[n - 1]);
Print[MantissaExponent[v[k]/v[k - 3] - Sqrt[2 - c[3]]/c[4]][[2]] //
   Abs, " computed digits of nested radical"];
This code produces the following output:
1506 computed digits of nested radical
It is interesting to note that due to relation
v k v k 1 2 2 2 + 2 = 2 1
we can compute 2 and its total numbers of correct digits by using the following command lines:
Print["Computed square root of 2 is ", N[1 + v[k]/v[k - 1], 20],"..."];
Print[MantissaExponent[(v[k]/v[k - 1] + 1) - Sqrt[2]][[2]] //
    Abs, " computed digits of square root of 2"];
,
This Mathematica command line generates the following output:
Computed square root of 2 is 1.4142135623730950488...
1506 computed digits of square root of 2
There are several different methods [23,24,25] that can be used for computing digits of 2 . However, the method of computation that we developed here can be implemented beyond 2 for efficient computation of the nested radicals with roots of 2 of kind
2 c n 1 c n .
These nested radicals are utilized in formulas like (23) and
π 4 = k 2 2 k 1 arctan 2 c k 1 c k .
Furthermore, due to relation
2 c n 1 c n 1 2 2 c n 1 , n 1 ,
this technique can also be applied for computation of the nested radicals with roots of 2 of kind
2 ± 2 + 2 + 2 + .
as an alternative to other known methods [10,16,26,27].

4.4. An Approximation to π with Arbitrary Convergence

Consider how equation (21) can be used for computing digits of π . Rather than to apply it directly for computing digits of π , we can apply equation (12) to transform quotient
1 θ 1 , k = v k 1 v k + 1
into reciprocal integers (compare equations (15) and (16) above before and after transformation). Another approach to compute π is to approximate θ k directly during process of iteration.
The following Mathematica code shows how to compute digits of π by approximating equation (34) in iteration process.
Clear[k, accNum, c, v1, vk, n]
(* Integer k *)
k = 50;
(* Define array of accuracy numbers *)
accNum = {100000, 200000, 300000, 400000, 500000};
(* Define nested radicals *)
c[0] := c[0] = 0;
c[n_] := c[n] = SetAccuracy[Sqrt[2 + c[n - 1]], k];
n = 1;
Do[
  (* Setting accuracy *)
  v1 = SetAccuracy[Floor[c[k]/Sqrt[2 - c[k - 1]]], accNum[[n]]];
  (* Computing v_k *)
  vk = v1; Do[vk = 1/2 (vk - 1/vk), k - 1];
  Print["n = ", n, ", ", MantissaExponent[\[Pi] -
      4*(2^(k - 1)*ArcTan[1/v1] + ArcTan[(vk - 1)/(vk + 1)])][[2]] //
          Abs, " digits of À"];
  n++, 5];
The output of this code is
n = 1, 100014 digits of À
n = 2, 200014 digits of À
n = 3, 300014 digits of À
n = 4, 400014 digits of À
n = 5, 500014 digits of À
The number of digits in the Mathematica code above is determined by list variable accNum consisting of a sequence of 5 numbers as given by
accNum = {100000, 200000, 300000, 400000, 500000};
If we increase these numbers, then the number of correct digits of π increases by the same factors. From this example we can see that by increasing parameters in the list variable accNum, we can archive an arbitrary convergence rate.

5. Conclusions

An iterative formula (20) that can be used for computing π and nested radicals with roots of 2 is derived. It is shown how this iterative formula can be implemented to generate and approximate the two-term Machin-like formulas for π . Developing this approach, a simple trigonometric formula for π with cubic convergence can be obtained. Some examples with Mathematica codes are provided.

Author Contributions

S.M.A. developed the methodology, wrote the codes and prepared a draft version of the manuscript. R.S., R.K.J. and B.M.Q. verified, reviewed and edited the manuscript. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data are contained within the article.

Acknowledgments

This work was supported by National Research Council Canada, Thoth Technology Inc., York University and Epic College of Technology.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Beckmann, P. A History of Pi; Golem Press: New York, NY, USA, 1971. [Google Scholar]
  2. Berggren, L; Borwein, J; Borwein, P. Pi: A Source Book, 3rd ed.; Springer-Verlag: New York, NY, USA, 2004. [Google Scholar]
  3. Borwein, J.; Bailey, D. Mathematics by Experiment—Plausible Reasoning in the 21st Century, 2nd ed.; Taylor & Francis Group: Abingdon, UK, 2008. [Google Scholar]
  4. Agarwal, R.P.; Agarwal, H.; Sen, S.K. Birth, growth and computation of pi to ten trillion digits. Adv. Differ. Equ. 2013, 2023, 100. [Google Scholar] [CrossRef]
  5. Lehmer, D.H.; On arccotangent relations for π. Amer. Math. Monthly. 1938, 45 (10), 657–664. http://www.jstor.org/stable/230243.
  6. Wetherfield, M. ; The enhancement of Machin’s formula by Todd’s process. Math. Gaz. 1996, 80(488), 333–344. [Google Scholar] [CrossRef]
  7. Gasull, A.; Luca, F.; Varona, J.L. Three essays on Machin’s type formulas. Indag. Math. 2023, 34, 1373–1396. [Google Scholar] [CrossRef]
  8. Abrarov, S.M; Quine, B.M. An iteration procedure for a two-term Machin-like formula for pi with small Lehmer measure. arXiv 2017, arXiv:1706.08835.
  9. The on-line encyclopedia of integer sequences. OEIS: A024810. Available online: https://oeis.org/A024810 (accessed on 17 September 2025).
  10. Campbell, J. Nested radicals obtained via the Wilf–Zeilberger method and related results. Maple Trans. 2023, 3, 16011. [Google Scholar] [CrossRef]
  11. Maritz, M.F. Extracting pi from chaos. Coll. Math. J., 2024, 55, 86–99. [Google Scholar] [CrossRef]
  12. Spíchal, L. Using the golden section to approximate π. Math. Mag. 2024, 97, 315–320. [Google Scholar] [CrossRef]
  13. Alferov, O. A rapidly converging Machin-like formula for π, https://arxiv.org/2403.09654.
  14. Kristiansen, T.B.; On Machin-like formula of arbitrary Lehmer measure. Two essays on the computation of π by inverse trigonometric functions, Master Thesis, Norvegian University of Science and Technology, Norway 2025.
  15. Campbell, J.M. An iterative approach toward hypergeometric accelerations. arXiv 2025, arXiv:2505.14392.
  16. Cho, S.; Kang, D.; Kim, R.; Lee, J.; Zhu, J. Chebyshev polynomials boost the π-series convergence. J. Korean Phys. Soc. 2025, 86, 1025–1036. [Google Scholar] [CrossRef]
  17. Abrarov, S.M.; Jagpal, R.K.; Siddiqui, R.; Quine, B.M. A new form of the Machin-like formula for π by iteration with increasing integers. J. Integer Seq. 2022, 25, 22.4–5. [Google Scholar]
  18. Störmer, C. Solution complète en nombres entiers de l’équation marctan1x+narctan1y=4. Bull. Soc. Math. Fr. 1899, 27, 160–170. [Google Scholar] [CrossRef]
  19. Chien-Lih, H. An elementary derivation of Euler’s series for the arctangent function. Math. Gaz. 2005, 89, 469–470. [Google Scholar] [CrossRef]
  20. Abrarov, S.M.; Siddiqui, R.; Jagpal, R.K.; Quine, B.M. A generalized series expansion of the arctangent function based on the enhanced midpoint integration. AppliedMath 2023, 3, 395–405. [Google Scholar] [CrossRef]
  21. Abrarov, S.M.; Siddiqui, R.; Jagpal, R.K.; Quine, B.M. A rational approximation of the two-term Machin-like formula for π. AppliedMath 2024, 4, 868–888. [Google Scholar] [CrossRef]
  22. Abrarov, S.M.; Quine, B.M. A formula for pi involving nested radicals. Ramanujan J. 2018, 46, 657–665. [Google Scholar] [CrossRef]
  23. Nimbran, A.S. Extending Euler’s product for 2. 2016, 47, 697–703. [CrossRef]
  24. Priestley, W.M. From square roots to n-th roots: Newton’s method in disguise. Coll. Math. J. 1999, 30, 387–388. [Google Scholar] [CrossRef]
  25. Kaushik, K.; Murphy, T. David Weed. Computing 2 with FRACTRAN, arXiv 2024, arXiv:2412.16185.
  26. Servi, L.D. Nested square roots of 2. Amer. Math. Monthly 2003, 110, 326–330. [Google Scholar] [CrossRef]
  27. Zimmerman, S.; Ho, C. On infinitely nested radicals. Math. Mag. 2008, 81, 3–15. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings

© 2025 MDPI (Basel, Switzerland) unless otherwise stated