A rational approximation of the
arctangent function and a new
approach in computing pi
S. M. Abrarov
and B. M. Quine
March 24, 2016
Abstract
We have shown recently that integration of the error function
erf (x) represented in form of a sum of the Gaussian functions provides
an asymptotic expansion series for the constant pi. In this work we
derive a rational approximation of the arctangent function arctan (x)
that can be readily generalized it to its counterpart sgn (x) π/2 +
arctan (x), where sgn (x) is the signum function. The application of
the expansion series for these two functions leads to a new asymptotic
formula for π.
Keywords: arctangent function, error function, Gaussian function,
rational approximation, constant pi
1 Derivation
Consider the following integral [1]
Z
0
e
y
2
t
2
erf (xt) dt =
1
y
π
arctan
x
y
, (1)
Dept. Earth and Space Science and Engineering, York University, Toronto, Canada, M3J 1P3.
Dept. Physics and Astronomy, York University, Toronto, Canada, M3J 1P3.
1
arXiv:1603.03310v2 [math.GM] 24 Mar 2016
where we imply that all variables t, x and y are real. Assuming that y = 1
the integral (1) can be rewritten as
arctan (x) =
π
Z
0
e
t
2
erf (xt) dt. (2)
The error function can be represented in form of a sum of the Gaussian
functions (see Appendix A)
erf (x) =
2x
π
× lim
L→∞
1
L
L
X
`=1
e
(`1/2)
2
x
2
L
2
. (3)
Consequently, substituting this limit into the equation (2) leads to
arctan (x) =
π × lim
L→∞
Z
0
e
t
2
2xt
πL
L
X
`=1
e
(`1/2)
2
x
2
t
2
L
2
| {z }
erf(xt)
dt.
Each integral term in this equation is analytically integrable. Consequently,
we obtain a new equation for the arctangent function
arctan (x) = 4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
x
2
+ 4L
2
. (4)
Since
π = 4 arctan (1)
it follows that
π = 16 × lim
L→∞
L
X
`=1
L
(2` 1)
2
+ 4L
2
. (5)
It should be noted that the limit (5) has been reported already in our recent
work [2].
2
-1.0
-0.5
0.5
1.0
x
-4. ´ 10
-7
-2. ´ 10
-7
2. ´ 10
-7
4. ´ 10
-7
Ε
Fig. 1. The difference ε over the range 1 x 1 at L = 100
(blue), L = 200 (red), L = 300 (green), L = 400 (brown) and
L = 500 (black).
Truncation of the limit (4) yields a rational approximation of the arctan-
gent function
arctan (x) 4L
L
X
`=1
x
(2` 1)
2
x
2
+ 4L
2
. (6)
Figure 1 shows the difference between the original arctangent function arctan (x)
and its rational approximation (6)
ε = arctan (x) 4L
L
X
`=1
x
(2` 1)
2
x
2
+ 4L
2
over the range 1 x 1 at L = 100, L = 200, L = 300, L = 400 and L =
500 shown by blue, red, green, brown and black curves, respectively. As we
can see from this figure, the difference ε is dependent upon x. In particular,
it increases with increasing argument by absolute value |x|. Thus, we can
conclude that the rational approximation (6) of the arctangent function is
more accurate when its argument is smaller. Consequently, in order to obtain
a higher accuracy we have to look for an equation in the form
π =
N
X
n=1
a
n
arctan (b
n
), |b
n
| << 1,
3
where a
n
and b
n
are the coefficients, with arguments of the arctangent func-
tion as small as possible by absolute value |b
n
|. For example, applying the
equation (6) we may expect that at some fixed L the approximation
π = 4 arctan (x = 1) 16L
L
X
`=1
1
(2` 1)
2
+ 4L
2
is less accurate than the approximation based on the Machin’s formula [3, 4]
π = 4
4 arctan
1
5
arctan
1
239

16L
L
X
`=1
4 (1/5)
(2` 1)
2
(1/5)
2
+ 4L
2
1/239
(2` 1)
2
(1/239)
2
+ 4L
2
.
Furthermore, with same equation (6) for arctan (x) we can improve accuracy
by using another formula for pi [4]
π = 4
12 arctan
1
18
+ 8 arctan
1
57
5 arctan
1
239

16L
L
X
`=1
12 (1/18)
(2` 1)
2
(1/18)
2
+ 4L
2
+
8 (1/57)
(2` 1)
2
(1/57)
2
+ 4L
2
5 (1/239)
(2` 1)
2
(1/239)
2
+ 4L
2
due to smaller arguments b
n
of the arctangent function.
2 Application
2.1 Counterpart function
Once the rational approximation (6) for the arctangent function is found,
from the identity
arctan
1
x
+ arctan (x) =
π
2
sgn (x) ,
where
sgn (x) =
1, x > 0
0, x = 0
1, x < 0
4
is the signum function [5], it follows that
4L
L
X
`=1
x
(2` 1)
2
+ 4L
2
x
2
π
2
sgn (x) + arctan (x) . (7)
Figure 2 shows the expansion series (7) computed at L = 100 (blue curve).
The arctangent function is also shown for comparison (red curve). As we can
see from this figure, on the left-half plane the expansion series (7) is greater
than the original arctangent function by π/2, while on the right-half plane it
is smaller than the original arctangent function by π/2.
- 3
- 2
- 1
1
2
3
x
- 1.5
- 1.0
- 0.5
0.5
1.0
1.5
Approximation for -
Π
2
sgnHxL + arctanHxL
Fig. 2. The expansion series (7) computed at L = 100 (blue curve)
resembling the function sgn (x) π/2 + arctan (x). The original arc-
tangent function (red curve) is also shown for comparison.
The approximation (7) can be replaced with exact relation by tending
the integer L to infinity and taking the limit as
4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
+ 4L
2
x
2
=
π
2
sgn (x) + arctan (x) . (8)
Since this limit represents a simple generalization of the equation (4), the
function sgn (x) π/2 + arctan (x) can be regarded as a counterpart to the
arctangent function arctan (x).
5
2.2 Asymptotic formula for pi
Using the limits (4) and (8) for the arctangent function arctan (x) and its
counterpart function sgn (x) π/2 + arctan (x), we can readily obtain an
asymptotic expansion series for pi. Let us rewrite the equation (8) as follows
arctan (x) =
π
2
sgn (x) 4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
+ 4L
2
x
2
. (9)
The difference of the equations (9) and (4) yields
0 =
π
2
sgn (x)
4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
+ 4L
2
x
2
!
| {z }
eq. (9)
4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
x
2
+ 4L
2
!
| {z }
eq. (4)
or
4 × lim
L→∞
L
X
`=1
Lx
(2` 1)
2
+ 4L
2
x
2
+
Lx
(2` 1)
2
x
2
+ 4L
2
=
π
2
sgn (x)
or
π = 8 × lim
L→∞
L
X
`=1
L |x|
1
(2` 1)
2
x
2
+ 4L
2
+
1
(2` 1)
2
+ 4L
2
x
2
(10)
since sgn (x) = x/ |x| [5]. Obviously, the equation (10) can be interpreted as
π = 2
|x|
x
arctan
1
x
+ arctan (x)
.
Remarkably, although the argument x is still present in the limit (10) this
asymptotic expansion series remains, nevertheless, independent of x. This
signifies that according to equation (10) the constant π can be computed at
any real value of the argument x R.
The limit (10) can be truncated by an arbitrarily large value L >> 1 as
given by
π 8L |x|
L
X
`=1
1
(2` 1)
2
x
2
+ 4L
2
+
1
(2` 1)
2
+ 4L
2
x
2
. (11)
6
We performed sample computations by using Wolfram Mathematica 9 in
enhanced precision mode in order to visualize the number of coinciding digits
with actual value of the constant pi
3.1415926535897932384626433832795028841971693993751 . . . .
The sample computations show that accuracy of the approximation limit
(11) depends upon the two values L and x (the dependence on the argument
x in the equation (11) is due to truncation now). For example, at L = 10
12
and x = 1, we get
3.141592653589793238462643
| {z }
25 coinciding digits
46661283621753050273271 . . . ,
while at same L = 10
12
but smaller x = 10
9
, the result is
3.14159265358979323846264338327950
| {z }
33 coinciding digits
305086383606604 . . . .
Comparing these approximated values with the actual value for the constant
pi one can see that at x = 1 and x = 10
9
the quantity of coinciding digits
are 25 and 33, respectively. It should be noted, however, that the argument
x cannot be taken arbitrarily small since its optimized value depends upon
the chosen integer L.
3 Conclusion
We obtain an efficient rational approximation for the arctangent function
arctan (x) that can be generalized to its counterpart function sgn (x) π/2 +
arctan (x). The application of the expansion series of the arctangent function
and its counterpart results in a new formula for π. The computational test
we performed shows that the new asymptotic expansion series for pi may be
rapid in convergence.
Acknowledgments
This work is supported by National Research Council Canada, Thoth Tech-
nology Inc. and York University. The authors would like to thank Prof. H.
Rosengren and Prof. L. Tournier for review and useful information.
7
Appendix A
Consider an integral of the error function (see integral 12 on page 4 in [6])
erf (x) =
1
π
Z
0
e
u
sin
2x
u
du
u
.
This integral can be readily expressed through the sinc function
{sinc (x 6= 0) = sin (x) /x, sinc (x = 0) = 1}
by making change of the variable v =
u leading to
erf (x) =
1
π
Z
0
e
v
2
sin (2xv)
2vdv
v
2
=
2
π
Z
0
e
v
2
sin (2xv)
dv
v
=
4x
π
Z
0
e
v
2
sin (2xv)
dv
2xv
or
erf (x) =
4x
π
Z
0
e
v
2
sinc (2xv) dv.
The factor 2 in the argument of the sinc function can be excluded by making
change of the variable t = 2v again. This provides
erf (x) =
4x
π
Z
0
e
t
2
/4
sinc (xt)
dt
2
or
erf (x) =
2x
π
Z
0
e
t
2
/4
sinc (xt) dt. (A.1)
As it has been shown in our recent publication, the sinc function can be
expressed as given by [7]
sinc (x) = lim
L→∞
1
L
L
X
`=1
cos
` 1/2
L
x
. (A.2)
8
From the following integral
sinc (x) =
1
Z
0
cos (xu) du =
1
x
x
Z
0
cos (t) dt (A.3)
it is not difficult to see that the cosine expansion (A.2) of the sinc function
is just a result of integration of equation (A.3) performed by using the mid-
point rule over each infinitesimal interval t = 1/L. There are many cosine
expansions of the sinc function can be found from equation (A.3) by taking
integral with help of efficient integration methods [8]. For example, another
cosine expansions of the sinc function can be found by using the trapezoidal
rule
sinc (x) = lim
L→∞
1
L
"
1 + cos (x)
2
+
L1
X
`=1
cos
`
L
x
#
(A.4)
and the Simpson’s rule
sinc (x) = lim
L→∞
1
6L
"
1 + cos (x) + 4
L
X
`=1
cos
` 1/2
L
x
+ 2
L1
X
`=1
cos
`
L
x
#
. (A.5)
It is interesting to note that the limit (A.5) can also be derived trivially as
a weighted sum of equations (A.2) and (A.4) in a proportion 2/3 to 1/3 as
follows
sinc (x) =
2
3
× lim
L→∞
1
L
L
X
`=1
cos
` 1/2
L
x
+
1
3
× lim
L→∞
1
L
"
1 + cos (x)
2
+
L1
X
`=1
cos
`
L
x
#
.
Any of these or similar cosine expansions of the sinc function can be used
in integration to obtain expansion series for the error function erf (x) and,
consequently, for the constant pi as well. However, as a simplest case we
consider an application of equation (A.2) only. Thus, substituting the cosine
expansion (A.2) of the sinc function into the integral (A.1) yields
erf (x) =
2x
π
× lim
L→∞
Z
0
exp
t
2
/4
1
L
L
X
`=1
cos
` 1/2
L
xt
| {z }
sinc(xt)
dt.
9
Each terms in this equation is analytically integrable. Therefore, its integra-
tion leads to the expansion series (3) of the error function. The more detailed
description of the expansion series (3) of the error function is given in our
work [2].
References
[1] H.A. Fayed and A.F. Atiya, An evaluation of the integral of the
product of the error function and the normal probability density
with application to the bivariate normal integral, Math. Comp., 83
(2014) 235-250. http://www.ams.org/journals/mcom/2014-83-285/
S0025-5718-2013-02720-2/
[2] S.M. Abrarov and B.M. Quine, A new asymptotic expansion series for
the constant pi, arXiv:1603.01462
[3] J.M. Borwein, P.B. Borwein and D.H. Bailey, Ramanujan, modular equa-
tions, and approximations to pi or how to compute one billion digits of pi,
Amer. Math. Monthly, 96 (3) (1989) 201-219. http://www.jstor.org/
stable/2325206
[4] J.M. Borwein and S.T. Chapman, I prefer pi: A brief history and an-
thology of articles in the American Mathematical Monthly, Amer. Math.
Monthly, 122 (3) (2015) 195-216. http://dx.doi.org/10.4169/amer.
math.monthly.122.03.195
[5] E.W. Weisstein, CRC Concise Encyclopedia of Mathematics, 2
nd
ed.,
Chapman & Hall/CRC 2003.
[6] E.W. Ng and M. Geller, A table of integrals of the error functions, J.
Research Natl. Bureau Stand. 73B (1) (1969) 1-20. http://dx.doi.org/
10.6028/jres.073B.001
[7] S.M. Abrarov and B.M. Quine, A rational approximation for efficient
computation of the Voigt function in quantitative spectroscopy, J. Math.
Research, 7 (2) (2015) 163-174. http://dx.doi.org/10.5539/jmr.v7n2
Preprint version: arXiv:1504.00322
[8] J.H. Mathews and K.D. Fink, Numerical methods using Matlab, 4
th
ed.,
Prentice Hall 1999.
10