If you were stranded on a desert island with only your laptop (and presumably a large solar panel), what software would you want to have with you? For me the answer definitely includes the latest version of Wolfram Mathematica. Whether you are a scientist, engineer, or mathematician, a Wall Street quant, a statistician or programmer, or even an artist or musician, you will be a better one if you have this tool at your disposal. Of course, having a tool and knowing how to use it well are quite different things. That is why I wrote the Mathematica Cookbook.
I am abig fan of O’Reilly cookbooks, as these books are designed to help you solve real-world problems. Mathematica is an ideal candidate for a cookbook because it is so vast, deep, and full of traps for the novice. I was ecstatic to learn that O’Reilly was looking to publish a Mathematica cookbook and even more excited when I was chosen to be its author. I have been a use r of Mathematica since version 3.0. Although that was over 13 years ago, I still remember the frustration of trying to solve problems in this system. I don’t mean this in a derogatory way. The frustration a newbie experiences when trying to learn Mathematica comes from the knowledge that you are sitting in front of a highly advanced computational platform that eventually will magnify your productivity tenfold—if you can only wrap your mind around its unfamiliar idioms. If you are a new (or even not-so-new) user of Mathematica today, you
are simultaneously in a better and a much worse position than I was with version 3.0.
You are in a better position because Mathematica 7.0 is vastly more powerful than 3.0 was back then. Not only has the number of available functions doubled, but Mathematica has fundamental new capabilities including dynamic interactivity, curated data sources, parallel processing, image processing, and much more. You are in a worse position because there is much more to learn! As Mathematica grows, it remains largely unchanged in its core principles. This book is designed to help you master those core principles by presenting Mathematica in the context of real-world problems. However, my goal is not just to show you how to solve problems in Mathematica, but to show you how to do so in a way that plays to Mathematica’s strengths. This means there is an emphasis on symbolic, functional, and pattern-based styles of programming. Mathematica is a multi-paradigm programming language; you can easily write code in it that a Fortran or C programmer would have little trouble following. However, the procedural style that this entails is not likely to give you good performance. More importantly, it will often cause you to write more code than necessary and spend more time adapting that code to future problems. Stephen Wolfram has said that a correct Mathematica program is often a short Mathematica program. There is much truth to this. The truth comes from the idea that good Mathematica programs leverage the capabilities of the vast built-in library of both general-purpose and highly specialized functions. Programming in Mathematica is a search for the right combination of primitives. My hope is that this cookbook will play a role as your guide.