An introductory programming text for the masses
Normally, I would avoid use of the word “programming” in a title for fear of immediately losing my audience but, as my readers seem to be mostly chemists and
![]() |
engineers, I may not have so much to fear (I think). This month’s column is a review of a really nice introductory text on programming with the Mathematica language. For a quick background on the program itself, see my last full review in the November 2003 issue of this journal. This text is based upon version 5.1, which was reviewed in September 2005. This high-level language is suitable for doing mathematics and graphics from simple high school algebra problems, to the challenging tests of theory that we may meet in graduate school. Along the way, it will greatly help the mathematicians, engineers and physical scientists solve their day-to-day problems that involve intense numbers crunching and sophisticated algorithms. That said, let’s look at the book.
A brief listing of the more pertinent chapter headings sets the tone: Lists, Functional/Procedural/Rules-based Programming, Recursion, Numerics, Graphics, Front-end Programming, Examples and Writing Packages. If this all sounds rather obscure and a bit advanced, take heart! The two introductory chapters on the Mathematica language provide a wonderful and very clear introduction to use on the beginners level. This introduction includes the standard ‘shift+enter’ to enter the expression and run the calculations, use of the keyboard and input palettes, and Mathematica’s famous (infamous?) curly brace/bracket formats. The new user is stepped through entering the program, writing expressions and executing them, getting out of trouble (always a very nice idea in a beginners programming text), and using the help browser. The instructions for actually typing the code and executing it are given in standard in[n]:= and out[n]= format that immediately displays what the program does for I/O (input/output). There is an all-too-brief box that shows some of the keyboard shortcuts for typesetting expressions, making mathematical symbolism a bit easier, but any omissions are addressed in Mathematica by the palettes that greatly simplify the implementation of these functions. Helpful hints such as use of the semicolon to suppress output and asterisks to comment lines of text are interspaced throughout these chapters.
Perhaps one of the most useful sections contains a few examples of Mathematics’ cryptic (but steadily improving) error messages. They briefly introduce the misspelling, non-existent function, and ‘wrong number of arguments’ errors but skip many more problematic ones. Also, there is a nice section on help functions that totally omits my personal favorite problem of not being able to invoke packages by a simple click in the help browser. This is a common problem if anything gets corrupted when loading or on subsequent additions to the desktop. The few other items having to do with errors are buried in the programming sections.
The chapter introducing the language does a masterful job of covering many of the most important features in just 21 pages, truly remarkable given the breadth and depth of the language. After quickly grounding the novice in logical operators and standard/functional forms of expressions, the authors delve into lists, one of the more important aspects of the program, as we oftentimes need to group and structure the data in order to present a proper format for subsequent analysis. This is especially important, as we continually assemble vectors and matrices to compute in n-dimensional space. For each topic, the logic flows from one specialized area to the next, often seamlessly integrated, through the series of I/O steps that illustrate the concept and specific usage. As with any new edition of a programming text, the errors may crop up, but they escaped your editor during first-pass reading.
With procedural programming, the book offers the more common steps seen in most technical programs such as looping, controlling the flow of execution, and logical constructs to build tests. Part of the value here is that the authors do not merely provide a few sample programs, but actually take the time to detail the value of writing your own. Once the novice becomes familiar with the basic concepts, tests of understanding are provided by chapter exercises. To further extend the value of these exercises, solutions are provided.
In the Preface, the authors state that “Oftentimes, the spectacular gains in processing power have not been met with similar advances in software. It often seems as if the power and utility of software are inversely proportional to their ease of use.” Fortunately for the non-professional programmer, Mathematica provides a simple and powerful tool, and books such as these do much to flatten the learning curve.
Availability
t 1An Introduction to Programming with Mathematica, 3rd ed., by Paul Wellin, Richard Gaylord, and Samuel Kamin. Cambridge University Press, New York; 570 pp. (2005); hardcover $70.00
John Wass is a statistician with GPRD Pharmacogenetics, Abbott Laboratories. He may be reached at [email protected].