Appendix A Numerical methods
A1 About numerical methods
In computational physics, many mathematical operations have to be carried out
numerically. Techniques for doing this are studied in numerical analysis. For a large
variety of numerical problems, commercial or public domain software packages are
available, and on the whole these are recommended in preference to developing all
the numerical software oneself, not only because this saves time but also because
available routines are often coded by professionals and hence are hard to surpass in
generality and efficiency. To avoid eventual problems with using existing numerical
software, it is useful to have some background in numerical analysis. Moreover,
knowledge of this field enables you to write codes for special problems for which
no routine is available. This chapter reviews some numerical techniques which are
often used in computational physics.
There are several ways of obtaining ‘canned’ routines. Commercially available
libraries (such as NAG, IMSL) are of very high quality, but often the source code
is not available, which might prevent your software from being portable. How-
ever, several libraries, such as the ones quoted, are available at many institutes and
companies for various types of computers (‘platforms’), so that in practice this
restriction is not so severe.
Via the internet, it is possible to obtain a wide variety of public domain routines;
a particularly useful site is/www.netlib.org/. Most often these are provided
in source code. Another cheap way of obtaining routines is by purchasing a book on
numerical algorithms containing listings of source codes and, preferably, a CD (or
an internet address) with these sources. A well-known book isNumerical Recipes
by Presset al.[1]. This is extremely useful: it contains very readable introductions to
various subjects in numerical mathematics and describes many algorithms in detail.
It explains the pros and cons of the methods and, most importantly, it explains what
can go wrong and why. Source codes are provided on diskette or CD in C, Fortran
and Pascal, although in some cases people have found it better to use routines from
NAG or Netlib. Apart fromNumerical Recipesthere are many excellent books in
557