William Smith is the engineering manager at Montana Software, a software development company specializing in custom applications for MS-DOS and Windows. You may contact him by mail at P.O. Box 663, Bozeman, MT 59771-0663.
A note on the cover claims that the book, C Mathematical Function Handbook, by Louis Baker, is a collection of programming tools for scientists and engineers. Although I know a few physicists that harbor an inordinate amount of professional pride and may consider the terms scientist and engineer mutually exclusive, the intended audience is clear. This book is for the technical folks. If your profession or field of study obliges you to feast on a diet of mathematical problems, statistics, differential equations, and numerical analysis, this book targets you.
I consider myself both an engineer and a scientist and appreciated what this book set out to accomplish. The author, Baker, touts this book as a C implementation of all the math functions in the classic book, Handbook of Mathematical Functions, by Abramowitz and Stegan (A&S). I own a copy of A&S and find it a valuable reference. More than once, I have had to implement in software one of the functions in A&S. Baker's book implements them all. Conveniently, he also uses C. This book covers everything from the more commonly encountered Bessel and Legendre functions to less familiar Mathieu and Struve functions. Most of the functions in the book arise from different classes of differential equations.
Organization
The organization of this book is quite different from what I am familiar with in a reference-style book. If there is such a category, I would call this book a "source code" book. Out of the 757 pages, I estimate at least 90% are dedicated to source listings. The first couple of chapters give some background. Baker mentions the IEEE-754 standard along with some caveats about C concerning floating-point math. Nothing very earthshaking here.Beginning with Chapter 3 the book coincides chapter by chapter with A&S. Each chapter begins with a few pages of text, followed by references and code listings. This book is by no means long-winded, yet the text is informative. It is a welcome addition to the dense concentration of information in the A&S book. The text gives a little background and describes how a particular math function arises. The text for each chapter contains a section on applications followed by a section discussing the methods used to implement the function. This format continues from Chapter 3 to Chapter 27.
Chapters 28 to 30 diverge slightly from this format, presenting C++ code in Chapter 29 and, Xref, a cross-reference utility, in Chapter 30. The Xref program generates a single-level call tree for each function. That is, it generates a list of functions that a given function calls and a list of functions that call a given function. This is a helpful tool for navigating someone else's source code. A function index and then a topic index finish off the book.
I have to admit that I would have preferred a reference-style book that listed the names of each of the functions in the collection with a description and specification of parameters, return values, and related functions. You can glean this information from the source-code listings, but it is not as visible. Baker intends the organization to parallel A&S. With this in mind, it seems to work.
Source Code
Since such a large portion of the book is devoted to source code listings, it is important to mention a few issues about them. Even though comments are sparse and variable names are terse, the source is quite readable. The listings are formatted in a easy-to-follow style and C keywords are bolded. Indentation is consistent from one listing to another. The few inconsistent brace locations and indentations are easy to tolerate.The code is a mix of ANSI C, K&R C, and even one group of listings in C++. Baker right up front mentions that the old K&R style of function declarations are obsolete, yet he uses them for the sake of portability. I wish he would have broken with the past and conformed to ANSI Standard C.
Another complaint about the code is that Baker does not take advantage of the ability to pass structures to functions and, similarly, return a structure from a function. This is an ANSI C feature and breaks from the convention of passing pointers to structures. For small structures such as the complex type, this can come in quite handy. It would make the C versions of his complex math functions much more natural and usable. Since the complex type structure is small, the stack does not get hammered too bad by doing this for these structures. I assume he choose to implement the complex math functions by passing pointers to be compatible with K&R C. If you can use C++, Baker provides a complete C++ complex math class with overloaded operators. Unfortunately, Baker jumps from K&R C to C++ avoiding ANSI C. Again, I would have preferred ANSI C.
All the code uses double precision. You can easily create a float version or a long double version of a certain function with a little editing and search and replace on the double keyword. The code is fairly granular. Baker isolates related functions into separate files. If you create a library for all the source code, only those object modules will be linked into your program that you actually need. This helps keep executable files small. Baker embeds some error processing into each function. Error messages are posted to stderr. Depending upon your user interface, you may not want error messages going to stderr and will have to make some code changes.
Conclusion
If you rarely dabble in floating-point math, this book will be of little use to you. In fact, many of the functions in this book the typical engineer will never encounter and never need. But, in my eyes, saving the time needed to implement just one function presented in this book is worth the price of the book. If you write mathematical software in C and already own and use A&S, C Mathematical Function Handbook may be a useful companion volume.Book Information
Title: The C Mathematical Function Handbook
Price: $49.95
McGraw-Hill
11 W. 19th St.
New York, NY 10011
(212) 337-5945
ISBN: 0-07-911158-8