You are on page 1of 10

Uniform Approximations for Transcendental

Functions

Serge Winitzki

Department of Physics, Ludwig-Maximilians University,


Theresienstr. 37, 80333 Munich, Germany
(serge@theorie.physik.uni-muenchen.de)

Abstract. A heuristic method to construct uniform approximations to


analytic transcendental functions is developed as a generalization of the
Hermite-Padé interpolation to infinite intervals. The resulting uniform
approximants are built from elementary functions using known series
and asymptotic expansions of the given transcendental function. In one
case (Lambert’s W function) we obtained a uniform approximation valid
in the entire complex plane. Several examples of the application of this
method to selected transcendental functions are given.

1 Introduction
Transcendental functions are usually solutions of analytic differential equations.
In most cases a few terms of the series expansion of the transcendental function
are easily obtained at certain points, e.g. x = 0 and x = ∞. However, these
expansions only give approximations at very small or very large x. It would be
useful to evaluate the function approximately at intermediate points 0 < x <
+∞. Common methods such as Lagrange interpolation, splines, or Chebyshev
polynomials do not provide a uniform approximation valid for all x ∈ (0, +∞).
The purpose of this article is to introduce a simple heuristic method for find-
ing uniform approximations to transcendental functions across an infinite range
of the argument. The approximants which we call the “global Padé approxi-
mants” are combinations of elementary functions. The method is in a certain
sense a generalization of Hermite-Padé approximation and requires the knowl-
edge of series expansions of f (x) at several points, including infinity. We obtained
uniform approximations for the elliptic function dn (x, m), the error function of
real and imaginary arguments, the Bessel functions J0 (x) and Y0 (x), and the
Airy function. The simplest approximants are often easily found by hand and
give a relative precision of a few percent, throughout an infinite range of the
argument. Finally, we give one example (Lambert’s W function) of a uniform
approximation valid throughout the entire complex plane.

2 Global Approximations of Nonsingular Functions


Here we consider the problem of approximating a function f (x) uniformly on
the real interval (0, +∞) when the function is regular within this interval. As a

V. Kumar et al. (Eds.): ICCSA 2003, LNCS 2667, pp. 780–789, 2003.

c Springer-Verlag Berlin Heidelberg 2003
Uniform Approximations for Transcendental Functions 781

first example, take the function f (x) defined for x ≥ 0 by the convergent integral
 ∞
e−xt dt
f (x) ≡ . (1)
0 t5 + 2t + 1

For x ≈ 0 the integrand is dominated by its growing denominator, while the


numerator remains close to 1. Therefore the first terms of the series expansion
of f (x) at x = 0 are obtained by expanding exp (−xt) near x = 0,

f2 2  
f (x) = f0 + f1 x + x + O x3 , (2)
2!
where the constants fk are found as
 ∞
k tk dt
fk ≡ (−1) , 0 ≤ k ≤ 3. (3)
0 t5 + 2t + 1

[Note that higher-order asymptotics at x = 0 require terms of the form xn ln x


and cannot be obtained in this naive way.] The asymptotic expansion at x → +∞
is obtained by expanding the denominator in t:
 
f (x) = x−1 − 2x−2 + 8x−3 + O x−4 . (4)

Neither this expansion nor the series at x = 0 provide a uniform approximation


for f (x). However, we may look for a rational function

p0 + p1 x + x2
r (x) = (5)
q0 + q1 x + q2 x2 + x3

where the constants pi , qi must be such that the expansions of r (x) at x = 0


and at x = +∞ coincide with Eqs. (2)-(4). We find that the constants should
be p0 ≈ 24.4, p1 ≈ 4.49, q0 ≈ 37.7, q1 ≈ 29.4, q2 ≈ 6.49. Numerical calculations
show that r (x) approximates f (x) with relative error < 10−2 for any x ≥ 0 (see
Fig. 1). Thus we are able to obtain a good plot of f (x) using only a few terms
of the series at both ends of the interval.

2.1 Global Padé Approximants

Let us consider the above approximation problem more formally. We need to


approximate a function f (x) which is finite everywhere in the interval (0, +∞).
Suppose that f (x) has certain series expansions at x = 0 and at x = +∞,
m−1

f (x) = ak xk + O (xm ) ≡ a (x) + O (xm ) , (6)
k=0
n−1
      
f (x) = bk x−k + O x−n ≡ b x−1 + O x−n . (7)
k=0
782 S. Winitzki

0.6

0.5

0.4

0.3

0.2

0.1

0 2 4 6 8 10
x

Fig. 1. A global Padé approximant of degree 3 (dashed line) for the function of
Eq. (1) (solid line).

Here a (x) and b (x) are known polynomials. We can assume that b0 = 1 in
Eq. (7). We can always reduce the problem to this case: we can divide f (x) by
its limit f (+∞) at x = +∞ if f (+∞ = 0). If f (+∞) = 0, the series at x = +∞
starts with a higher power of x−1 and we can multiply f (x) by the appropriate
power of x and by a nonzero constant to make b0 = 1.
We now look for a rational approximation of the form
p (x) p0 + p1 x + ... + pν xν
f (x) ≈ ≡ , (8)
q (x) q0 + q1 x + ... + qν xν
where ν is an appropriately chosen integer. The problem now is to find the
coefficients pi , qi such that Eq. (8) has the correct expansions at x = 0 and at
x = +∞. Since the leading term of the expansion of Eq. (8) at x = +∞ is pν /qν ,
we can set pν = qν = 1.
This formulation is similar to the problem of Hermite-Padé interpolation with
two anchor points [1], except that one of the points is at infinity where we need
to use an expansion in x−1 . We call a “global Padé approximant” an ansatz of
the form of Eq. (8). The unknown coefficients pi , qi are found from a system of
linear equations written compactly as

p (x) − q (x) a (x) = O (xm ) at x = 0, (9)


p (x) q (x)  −1   
ν
− ν b x = O x−n at x = +∞. (10)
x x
Here it is implied that the surviving polynomial coefficients in x or x−1 are
equated. This assumes that p (x) and q (x) have no common polynomial factors.
After the choice pν = qν = 1, Eqs. (9)-(10) are an inhomogeneous linear
system of (m + n − 1) equations for 2ν unknowns pi , qi , 0 ≤ i < ν. Therefore
a solution with lowest degree ν (when it exists) is unique if m + n is an odd
number. For small degrees ν it is easy to solve this system of equations by hand.
Heuristically, the approximation in Eq. (8) is the best when the orders m, n of
expansion are close to each other, m ≈ n.
Uniform Approximations for Transcendental Functions 783

It is important to note that the solution of Eqs. (9)-(10) with the lowest
degree ν does not always exist, and when it exists, q (x) sometimes has zeros
within the interval (0, +∞). In these cases one has to choose a higher degree ν.
One can show that the construction of “global Padé approximants” is equiva-
lent to Hermite-Padé interpolation after a projective transformation of the form

ax + b
x→ . (11)
cx + d
Our procedure is however more direct and easier to follow in hand calculations.

2.2 Global Approximations via Identities

The function f (x) = arctan x satisfies the identity π2 = arctan x1 + arctan x.


We may look for a rational function r (x) that satisfies the same identity. The
simplest such function,
π x
r0 (x) = , (12)
2 x+1
approximates arctan x with absolute error < 0.06 for all x ≥ 0.
As another example, consider the elliptic function dn (x, m) defined by
 1
dy
x=  . (13)
dn(x,m) (1 − y ) (y 2 − 1 + m)
2

Here m is a parameter, 0 < m < 1 (we follow the conventions of Ref. [2], Chapter
16). The function dn (x, m) is a periodic function of x (on the real line) with
the period 2K, where K ≡ K (m) is the complete elliptic integral. The function
dn (x, m) oscillates between the minimum and the maximum values at the end
points of the√half-period interval. The values of the extrema are dn (0, m) = 1;
dn (K, m) = 1 − m < 1. There is a Taylor series expansion

m2 x2 m (m + 4) x4  
dn (x, m) = 1 − + + O x6 (14)
2! 4!
and an identity √
dn (x,m) dn (K − x, m) = 1 − m. (15)
The obvious oscillatory approximation,
√ √
1+ 1−m 1− 1−m πx
dn (x, m) ≈ + cos , (16)
2 2 K
gives about 8% relative precision throughout the interval x ∈ [0, K]. We can
significantly improve the precision if we take into account Eq. (15). The function
 πx 
1/4 1 + b cos K
r1 (x, m) ≡ (1 − m)   (17)
1 − b cos πx
K
784 S. Winitzki

satisfies Eq. (15) for any b. The constant b is fixed by r1 (0, m) = 1. For testing,
we chose m = 0.9 because the approximation is worst when m is close to 1. We
found that the maximum relative error of Eq. (17) is less than 10−4 .
The precision can be improved by including more cosines. For instance, the
approximant
 πx   2πx 
1/4 1 + b1 cos K + b2 cos K 
r2 (x, m) = (1 − m)    2πx (18)
1 − b1 cos πx
K + b 2 cos K

satisfies Eq. (15), and the coefficients b1,2 may be chosen to reproduce the first
two terms of Eq. (14). Then the maximum relative error of r2 (x, m) for m = 0.9
is less than 10−11 .

3 Global Approximants for Singular Functions


In this section we consider the two-point approximation problem on the interval
(0, +∞) when the function has singularities at one or both ends of the interval.
If the function f (x) has a pole at a finite x = x0 , then we could multiply
f (x) by an appropriate power of (x − x0 ) and obtain a new function without
poles. If f (x) has a pole at x = +∞ with the asymptotic expansion of the form
f (x) = xl b0 + b1 x−1 + ... at x → +∞ [here l > 0], we should select the degree
of the polynomial q (x) in Eq. (8) to be l units less than the degree of p (x). Then
essentially the same procedure as above will yield a global Padé approximant for
the function f (x).
The presence of an essential singularity is usually clear from the asymptotic
expansion of the function f (x): the expansion contains a fractional power, an
exponential, or a logarithm of x. (Most often, the essential singularity is at
x = +∞.) It is impossible to reproduce an exponential, a logarithmic or a power
law singularity with rational functions. Instead we should try to build a global
approximant for f (x) by mixing polynomials with the elementary functions such
as ex or ln x in a suitable manner. A heuristic rule that works in many cases is
to write the asymptotic at x = +∞, find its other singularities, and replace x by
a rational function with undetermined coefficients to remove these singularities.

3.1 Error Function of Real Argument erf x


The error function  x
2 2
erf x ≡ √ e−x dx (19)
π 0
has well-known expansions at x = 0 and at x = +∞:
 
2 x3 x5  7
erf x = √ x− + +O x , (20)
π 3 10
2 
e−x 1 3  
erf x = 1 − √ 1 − 2 + 4 + O x−6 . (21)
x π 2x 4x
Uniform Approximations for Transcendental Functions 785

A heuristic approximation may be built using the approximate identity


√ −x2
2 πe 4x
(erf x) + erf x ≈ 1 ⇒ erf x ≈ √ 2
√ (22)
2x πe −x + πe−2x2 + 16x2
(the author is grateful to Matthew Parry for bringing this to his attention).
Equation (22) gives about 2% of relative precision for all real x. However, it is
not immediately clear how to improve the precision of this approximation.
We may transform the function erf x by the ansatz
2
e−x
erf x ≡ 1 − √ g (x) (23)
x π
and obtain the expansions of g (x) at x = 0 and at x = +∞,
√ √ 4  
g (x) = πx − 2x2 + πx3 − x4 + O x5 , (24)
3
1 3  −6 
g (x) = 1 − 2 + 4 + O x . (25)
2x 4x
The problem to approximate g (x) is now in the form of Sec. 2.1. We may obtain,
for instance, the following global Padé approximant of degree 2,

x π + (π − 2) x2
g (x) ≈ √ . (26)
1 + x π + (π − 2) x2
This provides a uniform approximation to erf x with an error less than 2%.

3.2 Error Function of Imaginary Argument erfi x


The error function of imaginary argument erfi x is defined as erf (ix) ≡ i erfi x.
The function erfi x has global approximants valid for all x ∈ (−∞, +∞), e.g.
2
ex p (x) p (x) 105 2 25 4 5 6
8 x + 4 x + 8x + x
8
r (x) = √ , ≡ 105 15 2 9 4 . (27)
x π q (x) q (x) 16 + 2 x + 2 x + 2x + x8
6

This approximates erfi x to within 6% of relative accuracy for all real x.


Higher-order approximants may be found explicitly:
n
  
(2k − 1)!! n
qn (x) = x2n−2k , (28)
2k k
k=0
n
 l
 k−1  
2l (−1) (2n − 2l + 2k − 1)!! n
pn (x) = x . (29)
2n−l (2k − 1)!! l−k
l=1 k=1

A numerical calculation suggests that the relative error can be estimated as






pn (x)
n


−n

qn (x) − erfi x
< 2 2
|erfi x| . (30)
786 S. Winitzki

3.3 The Bessel Functions J0 (x) and Y0 (x)

A more complicated example is provided by the Bessel functions J0 (x) and


Y0 (x). The series at x = 0 are

x2 x4  
J0 (x) = 1 − + + O x6
4 64
2γ 2 x x2 x  
Y0 (x) = + ln + γ − 1 + ln + O x4 ln x ,
π π 2 2π 2
where γ ≈ 0.5772 is Euler’s constant. The asymptotics at x = +∞ are
  
2 9x−2 π
J0 (x) = 1− sin x +
πx 128 4
 −1  
2 x 75x −3
π  
+ − + cos x + + O x−4 ,
πx 8 1024 4
   
−2
2 9x π
Y0 (x) = − 1− cos x +
πx 128 4
 −1  
2 x 75x −3
π  
+ − + sin x + + O x−4 .
πx 8 1024 4

There are several ways to build a global ansatz that matches these expansions.
It is clear that the oscillating functions and the square roots must be present in
the ansatz. We obtained the expressions
  
2 π x  π
J0 (x) ≈ sin x + − cos x + ,
π (0.123 + x) 4 2.64 + 8x2 4
      
2  π  x sin x + π4 ln 1 + 0.0364
2
Y0 (x) ≈ −   cos x + + 1+ √ x .
π 14 + x 4 1
3 + 8x
2 2 π

[The constant in the argument of the logarithm is 4 exp (−2γ − 2 π) ≈ 0.0364.]
These are perhaps the simplest, lowest-order global approximants accurate away
from zeros to about 2% for J0 (x) and to about 5% for Y0 (x) for all x ≥ 0 (see
Fig. 2). Although global approximants of this kind can be found for arbitrary
orders, the (numerical) solution of the required nonlinear equations becomes
more difficult for higher orders.

3.4 The Airy Function Ai (x)

The Airy function Ai (x) has two different asymptotic expansions at infinity,
 1 −1/4    
√ x exp − 23 x3/2 1 + O x−3/2 , x → +∞
Ai (x) ∼
2 π      , (31)
√1 x−1/4 cos 2 |x| − π4 1 + O x−3/2 , x → −∞
3/2
π 3
Uniform Approximations for Transcendental Functions 787

1 1

0.8
0.5

0.6 x
2 4 6 8 10
0

0.4

−0.5

0.2

−1

0 2 4 6 8 10
x

−1.5
−0.2

−0.4 −2

Fig. 2. Global approximants (dashed lines) for J0 (x) and Y0 (x) (solid lines).

whereas the Taylor expansion at x = 0 is


2
1 31/6 Γ  
Ai (x) = 2/3  2  − 3
x + O x3 . (32)
3 Γ 3 2π

It is difficult to build a single analytic ansatz for the whole real line, and for
practical purposes it is easier to approximate the Airy function separately in the
x > 0 and x < 0 domains. The simplest ansatz is
  
 √1 (x + a1 )−1/4 exp − 2 x3/2 , x > 0
Ai (x) ≈
2 π  3  . (33)
 √1 (|x| + a2 )−1/4 cos 23 |x|3/2 − π4 , x < 0
π

The constants a1 and a2 are chosen so that the value of the ansatz at x = 0
is correct. With the numerical values a1 ≈ 0.40, a2 = 4a1 ≈ 1.60 the ansatz of
Eq. (33) approximates the Airy function to about 20% for x < 0 and to about
2% for x > 0 (see Fig. 3).

0.4

0.2

–10 –8 –6 –4 –2 2

–0.2

–0.4

Fig. 3. Approximation of the Airy function Ai (x) by the ansatz of Eq. (33).

The ansatz of Eq. (33) is simple but gives a function with a discontinuous
derivative. This can be avoided with a more complicated ansatz, for instance,
788 S. Winitzki

−1/4
replacing (x + a) in Eq. (33) by a more complicated function. In practice,
Eq. (33) serves sufficiently well as a qualitative visualization of the Airy function.

3.5 Lambert’s W Function


Another example is Lambert’s W function defined by the algebraic equation

W (x) eW (x) = x. (34)

This function has real values for −e−1 ≤ x < +∞. We can use the series expan-
sions of W (x) at x = −e−1, x = 0 and x = +∞ to build global approximants
on the subintervals −e−1 , 0 and (0, +∞). The series at x = 0 and at x = −e−1
are
3  
W (x) = x − x2 + x3 + O x4 , (35)
2
1 11  
W (x) = −1 + y − y 3 + y 4 + O y 5 , (36)
3 72

where we defined y ≡ 2ex + 2. The asymptotic expansion at large |x| is
 2
ln (ln x) 1 ln (ln x)
W (x) ∼ ln x − ln (ln x) + + + ... (37)
ln x 2 ln x

A uniform approximation for x ∈ (0, +∞) can be obtained by replacing x in


the above asymptotic expansion by 1 + x or other suitable rational function. For
instance, the ansatz inspired by the first three terms of Eq. (37),
 
ln (1 + ln (1 + x))
W (x) ≈ ln (1 + x) 1 − , (38)
2 + ln (1 + x)

approximates W (x) for real x > 0 with a relative error less than 10−2 , while
ex
W (x) ≈ −1 (39)
1 + (2ex + 2)−1/2 + 1
e−1 − √1
2

is good for −e−1 ≤ x ≤ 1 and gives a relative error less than 10−3 .

4 An Approximation to W (x) in the Entire Complex


Plane
Here we present an approximant for W (z) which is valid for all (complex) z. The
practical significance of a global ansatz for W (z) is to provide a precise initial
approximation W0 for W (z), from which an efficient numerical computation of
W (z) for complex z is possible using e.g. the Newton-Raphson iteration.
The idea is to reproduce the first few terms of the asymptotic expansion of
W (z) at large |z| and of the series at z = 0 and at z = −e−1 . Since the expansion
Uniform Approximations for Transcendental Functions 789


at z = −e−1 uses y ≡ 2ez + 2 as the expansion variable while the asymptotic
expansion uses ln z, we need to combine terms of both kinds into one ansatz. We
choose an ansatz of the form
2 ln (1 + By) − ln (1 + C ln (1 + Dy)) + E
W (z) ≈ −1 . (40)
1 + [2 ln (1 + By) + 2A]
Here the constants A ≈ 2.344, B ≈ 0.8842, C ≈ 0.9294, D ≈ 0.5106, and E ≈
−1.213 are determined numerically to give approximately correct expansions at
the three anchor points to 3 terms.
Numerical computations show that Eq. (40) gives the complex value of the
principal branch of Lambert’s W function in the entire complex plane with
relative error less than 10−2 , with the standard choices of the branch cuts for

z and ln z.

5 Conclusion
In this paper, we have presented a heuristic method for approximating transcen-
dental functions f (x) using combinations of elementary functions. This method
is a generalization of the Hermite-Padé interpolation to infinite intervals and
non-rational functions. We showed several examples where the approximations
are easy to construct by hand, given the first few terms of series expansions of
f (x) at x = 0 and x = +∞. For functions with essential singularities, an ansatz
can usually be found by replacing Laurent series and arguments of powers and
logarithms by rational functions. The simplest approximants typically give a
precision of a few percent. The numerous examples suggest that the ansatz re-
sulting from this procedure will approximate the function across the entire range
of the argument, x ∈ (0, +∞).
In one case (Lambert’s W function) we were able to construct a global uni-
form approximant valid in the entire complex plane. This is a somewhat surpris-
ing result; it is probably due to the simple nature of the singularities of W (z). A
similar construction will certainly be impossible for some functions such as Γ (x)
or Riemann’s ζ (x) which are too ill-behaved for a full global approximation to
succeed. (However, it has been shown that these functions allow global uniform
approximants in the half-plane domains Re x > 0 for Γ (x) [4] and Re x > 1/2
for ζ (x) [3]; these are the domains where these functions are free of zeros and
poles, except for the singularity at x = +∞).

References
1. J. von zur Gathen and J. Gerhard, Modern Computer Algebra, Cambridge University
Press, 1999.
2. M. Abramowitz and I. Stegun, Handbook of special functions, National Bureau of
Standards, 1964.
3. P. Borwein, Canad. Math. Soc. Conf. Proc., 27 (2000), 29.
4. C. J. Lanczos, J. SIAM of Num. Anal. Ser. B, 1 (1964), 86; J. L. Spouge, J. SIAM
of Num. Anal. 31 (1994), 931.

You might also like