Book Reviews


Numerical Recipes In C

Reviewed By Dwayne Phillips


Dwayne Phillips works as a computer and electronics engineer with the United States Department of Defense. He has a Ph.D. in electrical and computer engineering at Louisiana State University. His interests include computer vision, artificial intelligence, software engineering, and programming languages.

Numerical Recipes in C is a text on numerical methods that has been revised for C programmers. Previous versions of this book were written for FORTRAN and Pascal audiences. This version contains much of the same text and material with the source code now written in C.

The authors call it a cookbook of numerical methods because it "reveals the individual ingredients and explains how they are prepared and combined." The authors' purpose for writing the book is "to open up a large number of black boxes to your scrutiny. We want to teach you to take apart these black boxes and put them back together again, modifying them to meet your needs." The authors succeed for the most part.

Numerical Recipes in C is a college textbook on numerical methods with one striking difference. That difference is source code. All of the numerical methods discussed are implemented completely in hundreds and hundreds of lines of C source code. It is this source code that makes the book so useful to the professional (and student alike). The source code probably rules out the book as a college text because the students would have the answers done for them. To the busy professional, however, having the source code to complex numerical routines is essential.

Numerical Recipes in C covers the usual topics for a numerical methods book and a few unusual ones. Figure 1 shows the chapter titles. The unusual topics include Sorting, Fourier Transform Spectral Methods, and Statistical Description of Data. These topics are more common to books on data structures, digital signal processing, and statistics. They are welcome additions here — especially the source code.

The book is easy to read. The authors use a conversational style rather than the dry style usually found in academic works. They give practical tips for using the functions in the book. For example, when solving N equations in N unknowns, they tell you that when using 32-bit floating point representation N can go up to 20 or 50. You should use 64 bits for N in the hundreds.

The authors provide several aids to help you use their text and source code. The first is a list of subroutine names with the chapter and section in which they are found. Next, they give a table of program dependencies. It tells you whether the routine you want to use needs any other numerical routines. This table shows that the vast majority of routines in the book are independent, i.e. they do not need a set of other functions for them to work. The authors also give an appendix of utility functions. These are short functions that almost all of the numerical functions use.

The publisher also provides several aids. The first is the complete source code on the Numerical Recipes C Diskette ($29.95 for PCs, also available for the Macintosh). This diskette is essential if you are using the functions listed in the book. The next aid is the 200-page book, Numerical Recipes Example Book (C) ($19.95). It contains source programs to call all of the functions in Numerical Recipes in C. The publisher also provides input data to demonstrate the functions. This source can be purchased on the Numerical Recipes Example Diskette (C) ($24.95). If you're going to buy the book, I suggest that you buy the disk, too.

The total package comes to $120. This is not cheap, but then what is knowledge worth in dollars? I think the disk sets are too expensive. Given that Numerical Recipes in C costs $45, the publisher should distribute the disk for a nominal charge.

The book is excellent as a quick reference. As a test, I decided to try solving N equations in N unknowns. The table of contents led me to the chapter on "Solution of Linear Algebraic Equations." I thumbed through a few pages until I encountered the routine for Gauss-Jordan elimination. A quick look at the text preceding the routine confirmed that this was the correct place. It took me an hour to type in the routine, which is shown in Listing 1. This should give you an idea of the style and readability of the code in the book. It took another few minutes to make up an example problem and a three-line calling routine. Except for typing in the source code, the process took about 15 minutes.

Who should buy this book? Do not buy it if you don't know the difference between integration and differentiation. Numerical methods is a deep mathematical subject that is boring and useless to the general public. If, however, you're a working programmer and need to crunch numbers from time to time, then this is a good reference book for you. If you are a college student majoring in engineering, physics, or math, this book will help you through some tough situations when you don't have time to reinvent the wheel. Finally, if you teach a college or high school course in which you crunch numbers in C, then you also can use Numerical Recipes in C.

Numerical Recipes in C — The Art of Scientific Computing
William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling.
Cambridge University Press, 1988
$44.50, 735 pages
ISBN O-521-35465-X book