Suggestions about Learning Mathematica
Getting Started
As with any other computer system, there are a few points that you need to get straight before you can even start using Mathematica. For example, you absolutely must know how to type your input to Mathematica. To find out these kinds of basic points, you should read at least the first section of Part 1 in this book.
Once you know the basics, you can begin to get a feeling for Mathematica by typing in some examples from this book. Always be sure that you type in exactly what appears in the book—do not change any capitalization, bracketing, etc.
After you have tried a few examples from the book, you should start experimenting for yourself. Change the examples slightly, and see what happens. You should look at each piece of output carefully, and try to understand why it came out as it did.
After you have run through some simple examples, you should be ready to take the next step: learning to go through what is needed to solve a complete problem with Mathematica.
Solving a Complete Problem
You will probably find it best to start by picking a specific problem to work on. Pick a problem that you understand well—preferably one whose solution you could easily reproduce by hand. Then go through each step in solving the problem, learning what you need to know about Mathematica to do it. Always be ready to experiment with simple cases, and understand the results you get with these, before going back to your original problem.
In going through the steps to solve your problem, you will learn about various specific features of Mathematica, typically from sections of Part 1. After you have done a few problems with Mathematica, you should get a feeling for many of the basic features of the system.
When you have built up a reasonable knowledge of the features of Mathematica, you should go back and learn about the overall structure of the Mathematica system. You can do this by systematically reading Part 2 of this book. What you will discover is that many of the features that seemed unrelated actually fit together into a coherent overall structure. Knowing this structure will make it much easier for you to understand and remember the specific features you have already learned.
The Principles of Mathematica
You should not try to learn the overall structure of Mathematica too early. Unless you have had broad experience with advanced computer languages or pure mathematics, you will probably find Part 2 difficult to understand at first. You will find the structure and principles it describes difficult to remember, and you will always be wondering why particular aspects of them might be useful. However, if you first get some practical experience with Mathematica, you will find the overall structure much easier to grasp. You should realize that the principles on which Mathematica is built are very general, and it is usually difficult to understand such general principles before you have seen specific examples.
One of the most important aspects of Mathematica is that it applies a fairly small number of principles as widely as possible. This means that even though you have used a particular feature only in a specific situation, the principle on which that feature is based can probably be applied in many other situations. One reason it is so important to understand the underlying principles of Mathematica is that by doing so you can leverage your knowledge of specific features into a more general context. As an example, you may first learn about transformation rules in the context of algebraic expressions.
But the basic principle of transformation rules applies to any symbolic expression. Thus you can also use such rules to modify the structure of, say, an expression that represents a Mathematica graphics object.
Changing the Way You Work
Learning to use Mathematica well involves changing the way you solve problems. When you move from pencil and paper to Mathematica the balance of what aspects of problem solving are difficult changes. With pencil and paper, you can often get by with a fairly imprecise initial formulation of your problem. Then when you actually do calculations in solving the problem, you can usually fix up the formulation as you go along. However, the calculations you do have to be fairly simple, and you cannot afford to try out many different cases.
When you use Mathematica, on the other hand, the initial formulation of your problem has to be quite precise. However, once you have the formulation, you can easily do many different calculations with it. This means that you can effectively carry out many mathematical experiments on your problem. By looking at the results you get, you can then refine the original formulation of your problem.
There are typically many different ways to formulate a given prob lem in Mathematica. In almost all cases, however, the most direct and simple formulations will be best. The more you can formulate your problem in Mathematica from the beginning, the better. Often, in fact, you will find that formulating your problem directly in Mathematica is better than first trying to set up a traditional mathematical formulation, say an algebraic one. The main point is that Mathematica allows you to express not only traditional mathematical operations, but also algorithmic and structural ones. This greater range of possibilities gives you a better chance of being able to find a direct way to represent your original problem.
Writing Programs
For most of the more sophisticated problems that you want to solve with Mathematica, you will have to create Mathematica programs. Mathematica supports several types of programming, and you have to choose which one to use in each case. It turns out that no single type of programming suits all cases well. As a result, it is very important that you learn several different types of programming.
If you already know a traditional programming language such as BASIC, C, Fortran, Perl or Java, you will probably find it easiest to learn procedural programming in Mathematica, using Do, For and so on. But while almost any Mathematica program can, in principle, be written in a procedural way, this is rarely the best approach. In a symbolic system like Mathematica, functional and rulebased programming typically yields programs that are more efficient, and easier to understand.
If you find yourself using procedural programming a lot, you should make an active effort to convert at least some of your programs to other types. At first, you may find functional and rulebased programs difficult to understand. But after a while, you will find that their global structure is usually much easier to grasp than procedural programs. And as your experience with Mathematica grows over a period of months or years, you will probably find that you write more and more of your programs in nonprocedural ways.
Learning the Whole System
As you proceed in using and learning Mathematica, it is important to remember that Mathematica is a large system. Although after a while you should know all of its basic principles, you may never learn the details of all its features. As a result, even after you have had a great deal of experience with Mathematica, you will undoubtedly still find it useful to look through this book. When you do so, you are quite likely to notice features that you never noticed before, but that with your experience, you can now see how to use.
How to Read This Book
If at all possible, you should read this book in conjunction with using an actual Mathematica system. When you see examples in the book, you should try them out on your computer.
You can get a basic feeling for what Mathematica does by looking at "A Tour of Mathematica" in Section T.0. You may also find it useful to try out examples from this Tour with your own copy of Mathematica.
Whatever your background, you should make sure to look at the first three or four sections in Part 1 before you start to use Mathematica on your own. These sections describe the basics that you need to know in order to use Mathematica at any level.
The remainder of Part 1 shows you how to do many different kinds of computations with Mathematica. If you are trying to do a specific calculation, you will often find it sufficient just to look at the sections of Part 1 that discuss the features of Mathematica you need to use. A good approach is to try and find examples in the book which are close to what you want to do.
The emphasis in Part 1 is on using the basic functions that are built into Mathematica to carry out various different kinds of computations.
Part 2, on the other hand, discusses the basic structure and principles that underlie all of Mathematica. Rather than describing a sequence of specific features, Part 2 takes a more global approach. If you want to learn how to create your own Mathematica functions, you should read Part 2.
Part 3 is intended for those with more sophisticated mathematical interests and knowledge. It covers the more advanced mathematical features of Mathematica, as well as describing some features already mentioned in Part 1 in greater mathematical detail.
Each part of the book is divided into sections and subsections. There are two special kinds of subsections, indicated by the following headings:
Advanced Topic: Advanced material which can be omitted on a first reading.
Special Topic: Material relevant only for certain users or certain computer systems.
The main parts in this book are intended to be pedagogical, and can meaningfully be read in a sequential fashion. The Appendix, however, is intended solely for reference purposes. Once you are familiar with Mathematica, you will probably find the list of functions in the Appendix the best place to look up details you need.
About the Examples in This Book
All the examples given in this book were generated by running an actual copy of Mathematica Version 5. If you have a copy of this version, you should be able to reproduce the examples on your computer as they appear in the book.
There are, however, a few points to watch:
Until you are familiar with Mathematica, make sure to type the input exactly as it appears in the book. Do not change any of the capital letters or brackets. Later, you will learn what things you can change. When you start out, however, it is important that you do not make any changes; otherwise you may not get the same results as in the book.
Never type the prompt In[n]:= that begins each input line. Type only the text that follows this prompt.
You will see that the lines in each dialog are numbered in sequence. Most subsections in the book contain separate dialogs. To make sure you get exactly what the book says, you should start a new Mathematica session each time the book does.
Some "Special Topic" subsections give examples that may be specific to particular computer systems.
Any examples that involve random numbers will generally give different results than in the book, since the sequence of random numbers produced by Mathematica is different in every session.
Some examples that use machineprecision arithmetic may come out differently on different computer systems. This is a result of differences in floatingpoint hardware. If you use arbitraryprecision Mathematica numbers, you should not see differences.
Almost all of the examples show output as it would be generated in StandardForm with a notebook interface to Mathematica. Output with a textbased interface will look similar, but not identical.
Almost all of the examples in this book assume that your computer or terminal uses a standard U.S. ASCII character set. If you cannot find some of the characters you need on your keyboard, or if Mathematica prints out different characters than you see in the book, you will need to look at your computer documentation to find the correspondence with the character set you are using. The most common problem is that the dollar sign character (Shift4) may come out as your local currency character.
If the version of Mathematica is more recent than the one used to produce this book, then it is possible that some results you get may be different.
Most of the examples in "A Tour of Mathematica", as well as Parts 1 and 2, are chosen so as to be fairly quick to execute. Assuming you have a machine with a clock speed of over about 1 GHz (and most machines produced in 2003 or later do), then almost none of the examples should take anything more than a small fraction of a second to execute. If they do, there is probably something wrong. Section 1.3.12 describes how to stop the calculation.
