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]
Nowadays, the identities of kind
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
Since according to this equation, we get
the convergence of the Machin-like formulas (
2) for
is always better when the values
are larger by absolute value.
To estimate efficiency of the Machin-like formulas for
, Lehmer introduced a measure, defined as [
5,
6,
7]
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 and smaller number of the summation terms J.
Generally, we should imply that Lehmer’s measure is valid only if all coefficients
are integers. Otherwise if
, its fractional parts
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
are integers.
The Machin-like formulas (
2) for
can be validated by using the following relation
The right side of this relation implies that the real part of the product must be equal to its imaginary part as follows
For example, the original Machin formula (
1) for
can be readily validated by applying this relation
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
where
is an integer (see [
9] for available values of
)
that can be computed by using the nested radicals such that
and
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
functions that can be defined as [
7]
Application of formula (
6) for determination of the coefficient
is not optimal. In particular, as integer
k increases the exponent
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
. The following theorem shows how else the constant
can be calculated.
Theorem 1.
There is a formula such that
Proof. From induction it follows that
Therefore, from equations (
6) and (
9), we obtain
Since
is a real number, the imaginary part of the equation above must be equal to zero. Consequently, we have
or
or
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
where
In the formula (
12), we imply that
such that at
the sum
is equal to zero. Consequently, when
the equation (
12) is reduced to
where
and
according to equation (
5) above. In fact, the equation (
12) can be obtained from equation (
5) together with the following identity [
17]
Consider how the two well-known Machin-like formulas for
can be derived by using equation (
12). At
and
equation (
12) results in
This equation is commonly known as the Hermann’s formula for
[
18]. At
and
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
into sum of arctangents with reciprocal integers. For example, at
we get
Consequently, applying two-step iteration (
8) we can find that
Substituting these values into equation (
12), results in
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
and
from equation (
12) it follows that
At
and
equation (
12) gives
Incrementing the integer
M over and over again, at
and
equation (
12) finally yields the 7-term Machin-like formula
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
and
where
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]
Equation (
18) can be derived by substituting
into the identity
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
with help of the two-step iteration (
8), we obtain
Consequently, the two-term Machin-like formula for
becomes
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
. Any our attempt to approximate
by two-step iteration (
8) either do not provide a desired accuracy or completely diverge from the value
. 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
and
equation (
12) results in
where argument in the second arctangent function contains
digits in the numerator and
digits in the denominator. In the recent publication, Gasull
et al. showed that at
number of digits in the numerator and denominator in the two-term Machin-like formula for
of kind (
5) are
and
, respectively (see Table 2 in [
7]). Consequently, the two-step iteration (
8) is appeared to be impractical for approximating the constants
.
This problem can be effectively resolved by using a new method of iteration that will be shown in the next section.
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
Proof. This is Ramanujan’s nested radical. Since
we can write
Then, solving the equation
or
we get two solutions
and
. Since the sequence
monotonically increases and positive at any
except
, we have to exclude the negative solution. Consequently, the theorem is proved. □
From the theorem 4 we can make a conclusion that
since due to relation
leading to
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
Proof.
Since
while
we can infer that
Therefore, we can write
from which it follows that
and proof of this lemma follows since [
22]
□
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
and
Since
is very close to unity, the double-term rational approximation (
25) can be simplified as
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 , at 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
Proof. Applying de Moivre’s theorem we can write
Substituting equation above into equation (
10) and taking into consideration that
we get
Consequently, the equation (
10) can be represented as
and this completes the proof. □
We may attempt to approximate the coefficient
. Since
with increasing
k, the equation (
27) can be approximated as
Since
the approximation above can be further simplified as
Using the following trigonometric identities
and
the equation (
28) can be expressed as
Since
converges faster to 1 than
we can simplify approximation (
29) as
Substituting approximation (
30) into equation (
13), we can approximate the two-term Machin-like formula (
1) for
as follows
Consequently, from the lemma 2 we have
Consider now the following limit
Since numerator of this limit is very close to its denominator near vicinity of
, we may replace tangent function in approximation (
31) with twice of square of sine function. This leads to
or
or
Equation (
32) provides a hint for computation of
. Using an heuristic assumption by change of the variable such that
we may attempt to compute
by using the following iteration
resulting in
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
Mathematica code below shows how to generate digits of the nested radicals with roots of 2 at
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
we can compute
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
. However, the method of computation that we developed here can be implemented beyond
for efficient computation of the nested radicals with roots of 2 of kind
These nested radicals are utilized in formulas like (
23) and
Furthermore, due to relation
this technique can also be applied for computation of the nested radicals with roots of 2 of kind
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
into reciprocal integers (compare equations (
15) and (
16) above before and after transformation). Another approach to compute
is to approximate
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.