Professional Documents
Culture Documents
Functions
Serge Winitzki
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.
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
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
p0 + p1 x + x2
r (x) = (5)
q0 + q1 x + q2 x2 + x3
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
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.
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 .
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.
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).
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.
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
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 .
√
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.