You are here

The Mathematica GuideBook for Programming

Publisher:

Springer

Number of Pages:

904

Price:

79.95

ISBN:

0387942823

By way of explanation: It is uncommon for MAA Reviews to post reviews on software; rarer yet on programming manuals or guides. In the past, because of its pedagogical value for younger people, I wrote a review of Stan Wagon’s Mathematical Explorer, an interactive survey of various mathematical concepts that was built on a “stripped-down” version of Mathematica.

I have been a light-weight user of Mathematica for some years now. I primarily used it as a very powerful “calculator”: a tool for simplifying, solving or manipulating equations encountered in reading, for evaluating integrals, for testing the equivalence of expressions, or for graphing real or complex functions to help gain insights. Only rarely did I need to write programs in Mathematica, and those I wrote generally only required writing a dozen or so short function definitions. Usually, I quickly got what I needed; occasionally I’d receive a strange series of error messages (often about something not being a “machine precision number”) and have to consult on-line documentation or books written about using Mathematica. The latter generally focused on “toy” problems and offered a quick, but superficial, explanation of the principles of the system or its true power. All too frequently, their longer programs would be difficult to understand, as they used efficient, but cryptic, constructs like Plus @@ (NIntegrate[#1, {x, #2[[1]], #2[[-1]]}]& @@@ %[[1]])

The Mathematica GuideBooks are a significant exception to this paradigm. Constructs like the above do appear, but the first volume explains these notations as needed that builds a basis of familiarity and understanding. While the four volumes explain how to use Mathematica’s many functions, they go well beyond this and are indeed books on solving vast classes of real problems in mathematics and physics. As emphasis for Trott’s understanding that Mathematica cannot be learnt only by reading, he concludes each chapter with a generous set of graded exercises and programming problems and, in a separate section he presents detailed analyses, author’s insights, and illustrative solutions to the problems. The following is the first part of a progressing 8-part exercise from the first volume:

18a) For an arbitrary 3 x 3 matrix A,

A3 – tr(A) A2 + ½ (tr(A)2 – tr( A2)) A – det(A) 1 = 0,

where tr is the trace, det is the determinant, and 1 is the 3D identity matrix. (This identity follows from the Theorem of Cayley–Hamilton together with the Newton relations.) [Using Mathematica,] prove this identity.

In all, I have taken over two years to read the four volumes cover-to-cover. They are far more than an encyclopedic treatment or reference manual to Mathematica . This review is the first of a series on the four GuideBooks; it looks specifically at the first volume. Although the publisher claims that each volume is self-contained, the first volume’s content is very much a prerequisite to the other volumes in the set. As noted below, each volume’s DVD provides the complete text of the full four-volume set.

Series Background. PhD solid-state physicist Michael Trott began using version 1.2 of Mathematica in his native Germany in mid-1990. In 1991-2, he developed a 1600-page set of lecture notes from which he began teaching an Introductory Course in Mathematica 2 and an advanced course on the Efficient Use of the Mathematica Programming System , given in 1991/1992 at the Technical University of Ilmenau, Germany. Because of this course, he was invited to join Wolfram Research in 1994 where he is now a senior developer. Over the years, he continued evolving the growing set of lecture to accommodate new Mathematica versions and features and their applications.

Springer-Verlag began publishing the 5,027 densely-printed pages of Michael Trott’s Mathematica GuideBooks in 2004. All four volumes have now been published. The individual books, largely self-contained, address Programming, Graphics, Numerics and Symbolics. Each volume comes with a multiplatform DVD-ROM that contains the complete text, executable programs and evaluated visualizations of the specific volume it accompanies. In addition, the DVD contains the complete text and executable programs of the other three volumes. The printed volumes are actually black-and-white printouts of the 16 notebooks on the DVD which also has a complete hyperlinked table of contents and index the full set. Additionally, the chapter-by-chapter notebooks contain internal hyperlinks to other sections and to hundreds of bibliographic references. Many references are linked to abstracts or papers available on the Internet. Because of the space limitations and cost of printed books, there is far more information in the DVD and its cross-referencing tools than could fit in the bound volumes. The notebooks are compatible with Mathematica versions 4 and 5.

Over the years, many mathematicians and physicists have become familiar with Michael Trott’s functions web site (http://functions.wolfram.com). It contains references to over 87000 formulas with nearly 11000 striking visualizations of elementary functions and pi. His mathematical artwork has become well-known, appearing on posters, T-shirts, and other Mathematica -related materials and logos.

Volume 1: Programming. This book has six chapters: “Introduction to Mathematica”; “Structure of Mathematica Expressions”; “Definitions and Properties of Functions”; “Meta-Mathematica”; “Restricted Patterns and Replacement Rules”; and “Operations on Lists, and Linear Algebra”. The book’s structure follows the general outline of Wolfram’s Mathematica Book . The similarity ends there.

The first chapter provides an extensive overview of Mathematica’s capabilities. The pace is terse and considerably more sophisticated than that of any introduction to Mathematica I’ve seen elsewhere. It includes detailed approaches to solving actual problems including the system of ordinary differential equations for the Burridge–Knopoff model for earthquakes, set of partial differential equations. The author states: “Some of the inputs shown and executed in this chapter represent an intermediate to advanced use of Mathematica. Readers new to Mathematica will probably not understand how they work, neither should they. These inputs and code pieces represent a cross section of the type of problems treated in this book. After reading the GuideBooks , the reader will have no problem understanding these programs.” As the volume progresses, Trott generously shows pedagogical examples but occasionally reverts to the phrase that some of the more obscure constructions “will become intelligible to the reader” later in the book in order that a specific point can be presented in a real (rather than a toy) context. Remarkably, Trott keeps this promise! In the exercises, Trott invites the reader to pick a problem to work on while reading through the series. He suggests over 100 such problems, mostly mathematical with about 30 requiring a sound theoretical background in physics. Examples include: How does one calculate the shape of the two pieces used to cover a baseball? Which point of a hypercube in n dimensions maximizes the product of the distances to its vertices? How does one model the shape of a cracking whip? How does one analytically map a polygon with a hole to an annulus? How does one model the sand flow in a hourglass? Each problem is accompanied by a list of bibliographical references.

The second chapter is a thorough examination of Mathematica expressions and numbers. It presents elementary and transcendental functions, simple and nested expressions, rational, symbolic, real and complex numbers. Structures of expressions and numbers are explored fully, from user- and internal-perspectives, with tree structures shown for nested expressions. This chapter begins to show how the list is the fundamental structure on which Mathematica is based.

The third chapter begins the development of programming Mathematica. In its first section, the third chapter, “Definitions and Properties of Functions,” quickly covers the basics shown in every users’ manual. The six remaining sections systematically develop the concept of functions and their definitions as lists with attributes. This chapter also explores how Mathematica makes extensive use of pattern-representation and interpretation. Somewhat arcane topics are treated at length, including the important notions of immediate and delayed interpretation, up-values and down-values. Finally, pure functions are discussed in the context of Church’s λ-Calculus. The chapter concludes with sections on mapping, iterating and composing Mathematica functions.

The fourth chapter, “Meta-Mathematica” deals with the semantics of Mathematica as a programming system. As in any programming system, users are likely to write programs that fail for obscure reasons and that require debugging. Currently, Mathematica has nearly 2000 commands, and their misuse can produce confusing system messages or baffling results. In this chapter, the very structures of Mathematica are treated as Mathematica objects, and evaluation semantics are treated in excruciating detail, making this possibly the most demanding chapter in the volume. Naming and scoping are treated along with a short treatise on various forms of iteration. Linguistic tools are introduced that can show the full semantic representation and internal bindings of any Mathematica expression. Additionally, Trott shows the use of Mathematica’s execution tracing and trapping tools.

The fifth chapter fully examines patterns and rule-based programming. Mathematica’s pattern notation and interpretation capabilities enable the writing of short and elegant programs that eliminate much of the procedural bookkeeping required in most programming languages. Patterns make it possible to write short program expressions that allow for treating special cases in the context of the special case. But, without deep understanding of the problem and its computational complexity, these tools can also produce very inefficient programs. After developing the variations on Boolean functions and patterns, Trott gives several interesting examples, including development of a short(!) program for evaluating certain complete elliptic integrals from basic principles, complete with definitions, rules and recursive relationships.

The final chapter treats lists and their manipulation in full generality and explores their application to linear and matrix algebra. Mathematica has an extensive set of linear algebra commands that allow one to use lists (vectors, generalized n-dimensional matrices and arrays) as primitive structures. The chapter develops several interesting program applications, including a crossword-puzzle generator, construction and solution of magic squares, and powers and exponents of matrices. The chapter concludes with an illustration of the Cayley-Hamilton Theorem and a wealth of challenging exercises. As a coda, a program is developed that goes through the Standard Mathematica Packages to identify the “Top 10 Built-in Commands”used in producing the distributed Mathematica system. It should come as little surprise to the reader of this review that these are, in order: List, Pattern, Blank, Set, Times, Power, Plus, Null, CompoundExpression, and SetDelayed.This list explains the emphasis Trott has placed on lists, patters and execution semantics in this volume.

Trott maintains a web site for the GuideBooks where additional examples, graphics galleries, and errata and can be found and downloaded. The graphics gallery is well worth the visit!

The Mathematica GuideBook for Programming provided this reviewer with insights into solving and visualizing problems by using Mathematica rather than the other way around. Its wealth of exercises, annotated solutions and integrated bibliographic references should make this set a valuable part of the library of any Mathematica user. I highly recommend it.

Marvin Schaefer (bwapast@erols.com) is a computer security expert and was chief scientist at the National Computer Security Center at the NSA, and at Arca Systems. He has been a member of the MAA for 39 years and now operates an antiquarian book store called Books With a Past.