Appendix A4. Sound Advice and Encouraging Words
Save early, save often
This may be the best advice you will get for working with any computer application. This, and a heads up about NotebookAuto save. This save feature is activated from the Preferences... dialogue (Mathematica menu on a Macintosh). Choose Notebook Options/File Options and put a check in the box for NotebookAutoSave. Once this is done your notebook will be automatically saved after each new input. We also suggest that you also become accustomed to pressing Command-S (Control-S on a PC) every once and a while. This is the keyboard equivalent for Save on the File menu. Certainly you will want to "do a save" as you finish a major part of a worksheet or are about to embark on a doubtful computation.
What you see may not be what you get
When you look at a Notebook on the computer screen, you see what might be called its "visible state". This is not the same as the "internal state", which we can think of as being what Mathematica sees in the Notebook. There are two kinds of problems that can arise.
Mathematica sees things that you cannot see
The internal state of Mathematica may not be distinguishing between different Notebooks that are active on the display. To see this, open Mathematica and execute the entry b = 2.
Now open a new Mathematica Notebook (Command-N) and use it to execute the entry "b" Mathematica will return a value of 2 for "b" even though the value was not assigned in that Notebook. This is referred to as "sharing the kernel". All open Notebooks store their values in the same kernel and they immediately take effect in all open Notebooks. This can be handy for experimentation, but remember: After the experimentation in a new Notebook any assignments made will become active in the original Notebook also.
You see things that Mathematica cannot see
When you quit Mathematica and save a Notebook, all of the output cells are saved with it. Then, when you load that Notebook later, the output is still visible. However, the internal state of Mathematica does not include any of this visible output. One way to "fix" this is by executing all the inputs, top to bottom, by choosing Kernel/Evaluation/Evaluate Notebook. As an alternative consider thinking about what you want to accomplish (always a good idea), and then working your way through the newly opened Notebook, executing only those entries that you think you will need to accomplish the task at hand. It may be as simple as redefining a variable or two.
Whenever, during the course of Notebook development, Mathematica seems to be unable, or unwilling, to obey an input command, consider "starting over" by choosing Kernel/Quit Kernel/Local and then choose Kernel/Start Kernel/Local. Then figure out exactly what other inputs are needed to accomplish the troublesome task. Execute only those inputs, then the troublesome input and hope for the best. If it still fails to "work" then at least you know that the visual state is also the internal state so the problem is probably with that particular input. Ask someone else to take a look at it.
The famous "e" error (and others)
Certain names and letters are reserved by Mathematica for specific uses. Examples include "D" (for differentiation), "Sqrt", "Sin", "Cos", "Exp", "Pi" (for the mathematical constant π = 3.14.. ), and "E" (for the mathematical constant e = 2.78...) Consider these examples.
Mathematica uses E for the base of the natural logarithm function. E in an input cell prints in the output cell as e.
In[15]:=
{E, N[E]}
Out[15]=
In[19]:=
Plot[ E^(-x), {x,-1,1} ]
Errors occur when e is used as if it were E.
In[20]:=
Plot[ e^(-x), {x,-1,1} ]
Mathematica uses Pi for the ratio of the circumference to the diameter of a circle.
In[16]:=
{Pi, N[Pi]}
Out[16]=
In[21]:=
Plot[ Sin[Pi*x], {x,-1,1} ]
Errors occur when pi is used as if it were Pi.
In[22]:=
Plot[ Sin[pi*x], {x,-1,1} ]
Moral: When you get a strange result or a syntax error and there doesn't seem to be anything wrong, look back in your worksheet to see if you used the wrong spelling for π or perhaps entered e^x instead of Exp[x] or E^x.
Some encouraging words help abounds
Mathematica's help facility is top notch and we hope you become accustomed to using it. Anytime a function seems to be acting up, or you want to learn about a new process, check the examples in the Help Browser. Just highlight the procedure name in the Notebook, pull down the Help menu, and choose the second item: Find Selected Function... . The help system is set up as a browser encouraging you to explore related issues, feel free. You can navigate back and forth between help pages by clicking on the arrow icons at the top of the Help browser window.
Take a tour
If you have not done so already, consider taking tour. You may select Tour directly from the left pane of the Help Browser. We also recommend the Tour of Mathematica available by first selecting The Mathematica Book in the left pane.
Created by Mathematica (December 9, 2004)