Sie sind auf Seite 1von 83

Numerics of Special Functions

Nico M. Temme
Nico.Temme@cwi.nl

CWI, Amsterdam

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.1/65

Contents
Literature

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects
Numerical methods

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects
Numerical methods
New approaches

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects
Numerical methods
New approaches
Why is new software needed ?

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects
Numerical methods
New approaches
Why is new software needed ?
What has to be done ?

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Contents
Literature
Some simple experiences
Numerical aspects
Numerical methods
New approaches
Why is new software needed ?
What has to be done ?
Present project

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.2/65

Literature
W. Gautschi (1975): Computational methods in special
functions - A survey.
Y.L. Luke (1969): The special functions and their
approximations.
Y.L. Luke (1977): Algorithms for the computation of
special functions.
C.G. van der Laan & N.M. Temme (1984): Calculation
of special functions.
D.W. Lozier & F.W.J Olver (1994) (and updates):
Numerical evaluation of special functions.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.3/65

Literature, Methods and Software


Baker (1992), Moshier (1989), Thompson (1997),
Zhang & Jin (1996), Numerical Recipes
Maple, Mathematica, Matlab, Macsyma
Collections of algorithms: NAG, IMSL, SLATEC, CERN
Published algorithms: ACM, CPC, Applied Statistics
Repositories: GAMS at NIST, Netlib

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.4/65

Some simple experiences


How to compute an integral ?
Another integral
Exponential integral: Ei(x) or Ei(z) ?
Take a special case
Scaling
Extra elementary functions
Example: Beta integral
Example: Confluent hypergeometric function

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.5/65

How to compute an integral ?


Consider
F () =

t +2i t2 +1

dt.

Maple 7, for = 10, gives


F (10) = .1837516481 + .5305342893i.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.6/65

How to compute an integral ?


Consider
F () =

t +2i t2 +1

dt.

Maple 7, for = 10, gives


F (10) = .1837516481 + .5305342893i.

With Digits = 40, the answer is


F (10) = .1837516480532069664418890663053408790017+
+0.5305342892550606876095028928250448740020i.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.6/65

Take another integral, which is almost the same:


Z
Z

t2 +2i t2 +1
t2 +2it
F () =
e
dt = G() =
e
dt.

Maple 7, for = 10, gives G(10) = .1387778781 1015 .

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.7/65

Take another integral, which is almost the same:


Z
Z

t2 +2i t2 +1
t2 +2it
F () =
e
dt = G() =
e
dt.

Maple 7, for = 10, gives G(10) = .1387778781 1015 .


With Digits = 40, the answer is G(10) = .16 1042 .

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.7/65

Take another integral, which is almost the same:


Z
Z

t2 +2i t2 +1
t2 +2it
F () =
e
dt = G() =
e
dt.

Maple 7, for = 10, gives G(10) = .1387778781 1015 .

With Digits = 40, the answer is G(10) = .16 1042 .


2
The correct answer is G() = e
and for = 10 we
have G(10) = 0.6593662989 1043 .

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.7/65

The message is: one should have some feeling about the
computed result.
Otherwise a completely incorrect answer can be accepted.
Mathematica is more reliable here, and says:
"NIntegrate failed to converge to prescribed accuracy after
7 recursive bisections in t near t = 2.9384615384615387".

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.8/65

By the way, ask Maple 7 to do the following integral


Z

2
t +2i t2
H() =
e
dt,

and the funny answer is, after some simplification,


2
H() = e [1 + signum(t) erf i],

where erf z is the error function.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.9/65

Another integral
Consider
F (u) =

uit

dt
,
t1i

u > 0.

Numerical quadrature gives F (2) = 0.934349 0.70922i.


Mathematica 4.1 gives for u = 2 in terms of the Meijer
G-function:
!
1
0,
2 ; 2 2i .
F (2) = G2,1
2,3
0, 0, 12
Mathematica evaluates: F (2) = 0.547745 0.532287i.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.10/65

Ask Mathematica to evaluate F (u):


F (u) = eiuu (0, iu u).

This gives F (2) = 0.16114 0.355355i.


So, we have three numerical results:
F1 = 0.934349 0.70922i,
F2 = 0.547745 0.532287i,
F3 = 0.16114 0.355355i.

Observe that F2 = (F1 + F3 )/2. F1 is correct.


Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.11/65

Maple:
F (u) = eiuu Ei(1, iu u) = eiuu (0, iu u)],

same as Mathematica. This is a wrong answer.


Next, Maple, after simplification, in terms of exponential
integrals:
F (2) = e2i2 Ei(1, 2i 2) + 2ie2i2 ,

giving F (2) = .9343493870 .7092195099i, which is the


correct answer.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.12/65

Exponential integral:

Ei(x) or Ei(z) ?

The exponential integrals are defined by

E1 (z) =
z

et
dt,
t

|ph z| < ,

Ei(x) =
x

Ei(x) =
x

x et
et
dt =
dt,
t
t

et
dt = E1 (x),
t

x > 0,

x < 0.

Maple requires real x in Ei(x), as is in agreement with this definition.


Mathematica accepts complex z in Ei(z), although The Mathematica Book (4th Ed., p. 765)
defines Ei(z) only for z > 0 by using a principal value integral. This is confusing.
The same happens in Gradshteyn & Ryzhik (Sixth Ed.): Ei(x) is only defined as above;
there is no proper definition of the exponential integral for complex argument.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.13/65

Take a special case


Parabolic cylinder functions are special cases of the 1 F1
functions, Kummer functions or Whittaker functions.
The Mathematica Book (4th Ed., p. 765) advises to use


U (a, z) = 2a/2 z 1/2 Wa/2,1/4 12 z 2 ,
but this is useless when z < 0.
Maple 7 uses the representations in terms of 1 F1 functions,
but this becomes very unstable when the parameters are
"large".

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.14/65

Scaling
The function (z) defined by

(z) = 2z z1/2 ez (z),


1
1
+
+ . . . , z ,
(z) 1 +
2
12z 288z
can be computed within machine precision for almost all
complex z . The precision in the gamma function itself
follows from the evaluation of the elementary function

2z z1/2 ez .

To avoid underflow and overflow, and to control accuracy, it


is very important to have scaled functions like (z)
available.
Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.15/65

The same holds for Bessel functions, parabolic cylinder


functions, and so on.
f
The scaled Airy function Ai(z)
defined by
Ai(z) = e

32 z 3/2

f
Ai(z)

can be computed very accurate for complex z (not close to


zeros of Ai(z)).
2 3/2

The scaling factor e 3 z completely determines the


accuracy if z is large and complex.
Again, scaled functions are very useful to avoid underflow
and overflow, and to control accuracy.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.16/65

Extra elementary functions


We have standard codes for
sin x,

ln x,

arctan x,

ex , . . .

but usually not for


sin x x
,
3
x

ln(1 + x)
,
x

arctan x x
,
3
x

ex 1
,...
x

for small values of x. It is not difficult to write efficient codes


(by using power series, for example). A standard package
for this type of elementary functions would be very useful.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.17/65

Example: Beta integral


The Beta integral can be written in the form
r
q
p
(p)(q)
p + q (p) (q) p ln(1 p+q
)+q ln(1 p+q
)
.
= 2
e

(p + q)
pq (p + q)
When p + q is large, all quantities at the right-hand side can
be computed in good relative precision if codes for ln(1 + x)
(for small x) and (x) (for large x) are available.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.18/65

Example: Confluent hypergeometric function


The standard solution of Kummers equation that is singular
at the origin can be written in the form



1 F1 (a; c; z)
1c 1 F1 (1 + a c; 2 c; z)
z
U (a, c, z) =
.
sin c (1 + a c)(c)
(a)(2 c)
For small z this can be used for computations.
However, for integer values of c, problems arise.
A careful analysis is needed to avoid numerical
cancellations.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.19/65

We have
U (a, c, z) =

fk xk ,

k=0

where
(1 c)

1
=
,
f0 =
sin c (1 + a c)(c)
(1 + a c)

and


z c

a
f1 =

.
sin c (1 + c)(1 + a c) (a)(2 c)

For small values of c the coefficient f1 is difficult to compute.


Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.20/65

An expansion in powers of c is not doable, because of all


higher derivatives of the gamma function.
The computation of f1 can be done if we have an algorithm
for




1
1
1
1 ( + )

1
, or
( ) ( + )
( )
for small values of ||, C.
The remaining fk can be obtained from recursions, if f1 is
available.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.21/65

Numerical aspects
Fixed precision or variable precision
Insight in function behavior
Selecting analytical tools
Selecting numerical methods
Stability of the algorithms
Efficiency of the algorithms
Underflow, overflow, scaling
Testing
High quality software

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.22/65

Fixed precision or variable precision


Fixed precision: efficiency
Variable precision: greater challenge

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.23/65

Insight in function behavior


Numerically satisfactory pair of solutions
Singular points, turning points
Influence of additional parameters
Stable representations

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.24/65

Selecting analytical tools


Are power series available ?
Are asymptotic expansions available ?
Are these uniform with respect to parameters ?
Are new expansions needed ?
Are integrals well conditioned ?
Are connection formulas available ?

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.25/65

Selecting numerical methods


Power series: convergent, asymptotic
Recursions, linear difference equations
Chebyshev expansions
Continued fractions
Quadrature: Gauss, trapezoidal
Uniform asymptotic expansions
Differential equations
Rational approximations, Pad, Chebyshev sense
Convergence acceleration

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.26/65

Stability of the algorithms


Rigorous error analysis ?
Connection formulas
An important source of errors: elementary functions
with large complex arguments

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.27/65

Efficiency of the algorithms


One universal algorithm ?
Power series if possible ?

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.28/65

Underflow, overflow, scaling


Avoid underflow or overflow by scaling
Discontinuous scaling factors may occur
Testing scaled functions: no guarantee

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.29/65

Testing
Wronskian relations
Contiguous relations
Other functional identities
Testing by using overlapping domains
Testing with multiple-precision algorithms
Comparison against a standard
Lozier (1996) Test service and reference software

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.30/65

High quality software


Refereed articles
Refereed software
Concern: maintenance

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.31/65

Numerical methods
Power series: convergent, asymptotic
Recursions, linear difference equations
Chebyshev expansions
Continued fractions
Quadrature, Gauss, trapezoidal
Uniform asymptotic expansions
Differential equations
Rational approximations, Pad, Chebyshev sense
Convergence acceleration

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.32/65

Power series: convergent, asymptotic


Estimating remainders
"Convergence" of asymptotic expansions
Domains: Where to use the series ?
Meaning of asymptotic expansions

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.33/65

Meaning of asymptotic expansions


Consider the expansion of the Kummer function:
#
"R1


ez z ac X (c a)n (1 a)n
1 F1 (a; c; z)
R
=
+
O
|z|
+
n
(c)
(a)
n! z
n=0
z a
(c a)

"S1
X (1)n (a)n (1 + a c)n
n=0

n! z n


+ O |z|S

#


eia ,

This expansion is valid for large complex z in certain


sectors, but also for positive z .

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.34/65

Meaning of asymptotic expansions


Consider the expansion of the Kummer function:
#
"R1


ez z ac X (c a)n (1 a)n
1 F1 (a; c; z)
R
=
+
O
|z|
+
n
(c)
(a)
n! z
n=0
z a
(c a)

"S1
X (1)n (a)n (1 + a c)n
n=0

n! z n


+ O |z|S

#


eia

This expansion is valid for large complex z in certain


sectors, but also for positive z .
Observe that eia is a complex quantity.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.34/65

Meaning of asymptotic expansions


Consider the expansion of the Kummer function:
#
"R1


ez z ac X (c a)n (1 a)n
1 F1 (a; c; z)
R
=
+
O
|z|
+
n
(c)
(a)
n! z
n=0
z a
(c a)

"S1
X (1)n (a)n (1 + a c)n
n=0

n! z n


+ O |z|S

#


eia

This expansion is valid for large complex z in certain


sectors, but also for positive z .
Observe that eia is a complex quantity.
If z > 0, a and c are real: Does this formula give a complex
approximation of a real function ?
Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.34/65

Recursions, linear difference equations


First and second order difference equations
Stability analysis
Backward recursion
Nonlinear recursions: Gauss, Landen, AGM

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.35/65

Chebyshev expansions
Clenshaw, Luke: one variable, tabled coefficients
Luke: hypergeometric functions
(z)a U (a, c, z) =

Cn (z)Tn (1/),

n=0

where Tn is the shifted Chebyshev polynomial, 1 ,


z 6= 0, |ph z| < 3/2.
The coefficients Cn (z) are known as Meijers G function,
and Cn (z) satisfy a third order linear difference equation
If |ph z| < the Cn (z) can be computed by using a
backward recursion scheme.
Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.36/65

Continued fractions
Upper and lower approximations
Transformations
Stopping criterion
Anomalous convergence (Gautschi (1977))

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.37/65

Quadrature, Gauss, trapezoidal


Gauss quadrature: for fixed precision
Trapezoidal rule: more flexible
Select suitable contours: avoid strong oscillations
G() =

t +2it

dt = e

s2

ds.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.38/65

Uniform asymptotic expansions


Computation of coefficients
Domains: Where to use the expansions ?
Main approximants: higher transcendentals
For example, the Airy-type expansion for the J Bessel
function: as
"
#

0
Ai( 2/3 ) X As () Ai ( 2/3 ) X Bs ()
J (z) ()
+
,
2s
2s
1/3
5/3

s=0
s=0
() =

4
1 z2

1/4

2 3/2

1 + 1 z2 p
= ln
1 z2.
z

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.39/65

Differential equations
Stability
Direction of integration
Parallel integration (Lozier & Olver (1993))
Higher order linear equations
Lanczos method (Coleman, Rappoport)

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.40/65

Chebyshev sense
Rational approximations, Pade,
Cody and co-workers: one variable rational
approximations
Pad: applicable when coefficients can be obtained
easily
Luke: tabled coefficients

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.41/65

Convergence acceleration
Summing slowly convergent series
Summing divergent asymptotic series
Brezinski, Weniger
Special examples show impressive results

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.42/65

New approaches
Elementary functions: rigorous bounds
Multiple-precision computations
Unrestricted algorithms, error analysis
Methods for computing symmetric integrals
New packages for special functions

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.43/65

Elementary functions: rigorous bounds


Cody & Waite (1980)
Table-lookup algorithms ((Tang (1991), Rump (2001))
Zimmerman (France): The MPFR library
(www.mpfr.org)
Cuyt & Verdonk (Belgium): continued fraction approach

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.44/65

Multiple-precision computations
Brent (1978): Fortran
Several packages in C, C++
Maple, Mathematica, ...

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.45/65

Methods for computing symmetric integrals


Main application: elliptic integrals.
Carlsons method: To iterate the duplication theorem and
then sum a five degree power series.
The symmetric integrals are of the form:
Z
1
RF (x, y, z) =
[(t + x)(t + y)(t + z)]1/2 dt,
2 0
Z
3
RJ (x, y, z) =
[(t + x)(t + y)(t + z)]1/2 (t + p)1 dt,
2 0
The algorithms are very efficient and reliable.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.46/65

New packages for special functions


Gautschi (1994): ORTHOPOL, also for Gauss-type
quadrature rules
Koepf (1999): orthogonal polynomials, hypergeometric
functions (numerics and symbolic)
Zeilberger (1990, ...) (and others): hypergeometric
identities

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.47/65

Why is new software needed ?


Are other software efforts still needed with the libraries of
Mathematica and Maple available ?
A few remarks:
Refereed software
Repositories of free software
Fast algorithms in Fortran77, Fortran90, C, C++

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.48/65

What has to be done ?


Reliable software for large parameter cases
Appropriate scaling to avoid underflow and overflow
Complex variables
The land beyond Bessel
Integrals of special functions
q special functions ?

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.49/65

Present project
(In collaboration with Amparo Gil and Javier Segura,
Madrid).
Airy functions
Scorer functions
Kia (x), <Iia (x), x > 0, a IR

Parabolic cylinder functions for real arguments


Main tool: quadrature of integrals on complex contours,
with saddle point analysis

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.50/65

Quadrature of integrals
A simple example is:
Z
Z
t2 +2it
2
G() =
e
dt = e

s2

ds.

This makes sense, because


The new integral is real, without oscillations
The dominant term

is in front of the new integral

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.51/65

The function Kia(x)


An integral representation:
Z
Kia (x) =
ex cosh w+iaw dw.

Consider the case 0 a < x for which values Kia (x) > 0,
although strong oscillations occur in the integral when a, x
are both large.
Deform the contour such that no oscillations occur.
Write w = u + iv ; we have
x cosh w + iaw = x cosh u cos v av + i(x sinh u sin v + au).

Take the imaginary part equal to zero.


Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.52/65

/2

v0

This happens when, see the figure,


a u 
v = arcsin
.
x sinh u

The contour runs through the saddle point at


a
v0 = arcsin
.
x
Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.53/65

Integrate along this contour. Then, for 0 a < x,


Z
Z
Kia (x) =
e(u) f (u) du = e(0)
e[(u)(0)] du

where
(u) = x cosh u cos v + av,

and f (u) =

dw
du

dv
= 1 + i du
.

(0) =

x2 a2 + a arcsin(a/x),

The function (u) is positive. The factor e(0) gives the


dominant term in the asymptotic behaviour.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.54/65

Trapezoidal rule
b
a

n1

1
f (t) dt = h[f (a) + f (b)] + h
f (h j) + Rn ,
2
j=1

h=

ba
.
n

Compared with Gauss quadrature: very flexible;


precomputed zeros and weights are not needed.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.55/65

Trapezoidal rule
b
a

n1

1
f (t) dt = h[f (a) + f (b)] + h
f (h j) + Rn ,
2
j=1

h=

ba
.
n

Compared with Gauss quadrature: very flexible;


precomputed zeros and weights are not needed.
Error term, for some (a, b):
n h3 00
Rn =
f ().
12

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.55/65

Trapezoidal rule
b
a

n1

1
f (t) dt = h[f (a) + f (b)] + h
f (h j) + Rn ,
2
j=1

h=

ba
.
n

Compared with Gauss quadrature: very flexible;


precomputed zeros and weights are not needed.
Error term, for some (a, b):
n h3 00
Rn =
f ().
12

Adaptive algorithm: use previous function values


(h h/2).

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.55/65

Example: fast convergence


Take as an example the Bessel function (h = /n, x = 5)
J0 (x) =

cos(x sin t) dt = h + h

n1
X

cos [x sin(h j)] + Rn ,

j=1

Rn

.12 100

.48 106

16

.11 1021

32

.13 1062

64

.13 10163

128

.53 10404

Much better than the estimate of Rn . Explanation:


periodicity and smoothness.
Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.56/65

The remainder: smooth and periodic


In fact we have
Theorem

If f (t) is periodic and has a continuous k th derivative, and if


the integral is taken over a period, then
constant
|Rn |
.
k
n

Bessel function: we can take any k .


See Luke (1969) (Vol. II, p. 218). Krumhaar (1965) derives:
|Rn | 2ex/2

(x/2)2n
,
(2n)!

which is quite realistic for the value of x we chose.


Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.57/65

The trapezoidal rule on IR


For integrals over IR the trapezoidal rule may again be very
efficient and accurate.
Consider
Z

f (t) dt = h

f (hj + d) + Rd (h)

j=

where h > 0 and 0 d < h.


We use this for functions analytic in the strip:
Ga = {z = x + iy

x IR, a < y < a}.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.58/65

A class of analytic functions


Let Ha denote the linear space of functions f : Ga C,
which are bounded in Ga and for which
lim f (x + iy) = 0

(uniformly in |y| a) and


Ma (f ) =
lim
ba

|f (x ia)| dx =

|f (x ib)| dx < .

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.59/65

The error is exponentially small


Theorem

Let f Ha for some a > 0, and f even. Then


ea/h
Ma (f ),
|Rd (h)|
sinh(a/h)

for any y with 0 < y < a.


Proof

The proof is based on residue calculus.


See [13] (Vol. II, p. 217).

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.60/65

Example: modified Bessel function


Consider the modified Bessel function
Z
1
K0 (x) =
ex cosh t dt.
2
We have, with d = 0,
1
e K0 (x) = h + h
2
x

ex(cosh(hj)1) + R0 (h).

j=1

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.61/65

For x = 5 and several values of h we obtain (j0 denotes the


number of terms used in the series)
h
1
1/2
1/4
1/8
1/16
1/32
1/64

j0
2
5
12
29
67
156
355

R0 (h)
.18 101
.24 106
.65 1015
.44 1032
.19 1066
.55 10136
.17 10272

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.62/65

Fast convergent; easy to program


We see in this example that, halving the value of h gives
a doubling of the number of significant digits.
Roughly speaking, a doubling of the number of terms
needed in the series.
When programming this method, observe that when
halving h, previous function values can be used.
Details on error bounds for the remainder in this
example follow from Luke (1969).

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.63/65

Concluding remarks
There is a need for refereed software in the open
literature; further activities are needed.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.64/65

Concluding remarks
There is a need for refereed software in the open
literature; further activities are needed.
Maple and Mathematica are doing a great job, in
particular in connection with multiple-precision
numerics for special functions.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.64/65

Concluding remarks
There is a need for refereed software in the open
literature; further activities are needed.
Maple and Mathematica are doing a great job, in
particular in connection with multiple-precision
numerics for special functions.
Sometimes the approaches in M&M are too general;
the user should be alert when using these packages.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.64/65

Concluding remarks
There is a need for refereed software in the open
literature; further activities are needed.
Maple and Mathematica are doing a great job, in
particular in connection with multiple-precision
numerics for special functions.
Sometimes the approaches in M&M are too general;
the user should be alert when using these packages.
For large variables and complex variables, quadrature
methods for contour integrals are useful tools; ideas
from asymptotic analysis are very fruitful here.

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.64/65

Thanks to ...
Thanks to

Frdric Goualard,
who developed

prosper

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.65/65

Thanks to ...
Thanks to

Frdric Goualard,
who developed

prosper

A new LATEXclass to produce high quality slides


See also SIAM News, December 2001 and
http://prosper.sourceforge.net

Numerics of Special Functions, IMA, Special Functions in the Digital Age, July 2002 p.65/65

Das könnte Ihnen auch gefallen