Introduction
Different people have different ideas of what it means to program in Mathematica. To some, programming in Mathematica means using the myriad of powerful built-in functions to create “one-liners” that perform nontrivial calculations with a minimum of effort. To others, it means defining new functions that extend the capabilities of the system in some way. More advanced users want to place their function definitions in separate files, called packages, that encapsulate the details of the implementation. This book is intended to be a comprehensive reference to programming in Mathematica. In addition to all of the above, we attempt to assemble under a single cover many advanced techniques that either are scattered around the existing literature or can’t be found at all. These techniques, which we group under the moniker power programming, deal with issues such as: overriding built-in functions; making user-defined functions behave as much like the built-in ones as possible; adding new abstract data types; changing the global behavior of the system; tuning Mathematica code for performance; and using the MathLink inter-program communication protocol. We also devote an entire chapter to the much-neglected topic of debugging Mathematica programs. This introduction takes you on a tour through ever-increasingly advanced programming examples, beginning with the simplest imaginable and concluding with a demonstration of some of the more sophisticated programs developed in this book. In the course of doing so, the author hopes to provide the reader with a better idea of what power programming is all about, and how this book differs from existing ones. If your experience with Mathematica is very limited, you may wish to review the basic syntax of the language in the next chapter before continuing with this one.