As computer power and memory have increased, so has the capacity of software developers to write programs that assist people with time-consuming tasks. Mathematica is such a program. It works on problems that are impractical to do by hand, freeing your time for your own work. Mathematica is a useful tool for those who do quantitative analysis, symbolic calculations and manipulations, as well as for those who want to visualise functions or data. With it you can calculate, model, prototype and analyse results.
Mathematica performs three basic types of computation: numerical, symbolic, and graphical. It works with numbers of arbitrary magnitude and precision, as well as with polynomials, power series expansions, matrices, and graphs. Mathematica provides standard symbolic operations of algebra and calculus, including integration and differentiation. It can also plot functions and data in two or three dimensions.
Mathematica is an interpreted language---it reads an expression, evaluates the result, and then prints it out. Being interactive makes it easier to use than compiled languages such as C, FORTRAN, or Pascal.
Mathematica was designed to be extensible by including its own programming language. It is flexible and extremely useful software for anyone who regularly performs complicated mathematical computations.
Using Mathematica is like having a conversation. Ask a question and Mathematica responds with a result. Mathematica assigns a number in sequence for each input output pair or exchange. The nth user input in a Mathematica session is labelled In[n] and the corresponding computer output is labelled Out[n]. You can refer to earlier inputs and output with these labels.
Mathematica is started with the command math (or mathematica for X terminal users) entered at the Unix prompt. In the following `conversation' we ask Mathematica for the value of 5 to the power of 10 .
In[1]:= 5^10 (X terminal users press Shift-RET)
Out[1]= 9765625
In[2]:=
In[2]:= %1^(1/10)
Out[2]= 5
In[3]:=
In[3]:= % + a
Out[3]= 5 + a
If you assign a name to a result, you can later reference that result
with the assigned name. The command boatLength = 3 causes the
interpreter to associate the value 3
with the name boatLength
.
In[4] := boatLength = 3
Out[4] = 3
In[5] := boatLength
Out[5] = 3
In[6] := 20 boatLength
Out[6] = 60
In[4]:= ^d
% (Unix prompt)
As an alternative, Mathematica can be run from the editor Emacs. (See Emacs.) A special `mode' of the editor is available for this purpose where editing and execution of expressions occur `seamlessly'.
The library has reference material and tutorials on Mathematica.
Hard copy graphics output
First method:
To save a graphics plot in a file and to produce hard-copy, use something similar to this sequence:
In[1]:= myplot = Plot[Sin[x],{x, 0, 2Pi}]
Out[1]= -Graphics-
In[2]:= Display["myfile", myplot]
Out[2]= -Graphics-
In[3]:= !psfix myfile | lpr -P9 (prints using laser printer 9)
The raw graphics in myfile can printed out anytime when at the Unix prompt by the command,
% psfix myfile | lpr -P9
In[2]:= Display["myfile", %]'
% psfix myfile >myfile.ps
Second method:
To produce hard-copy directly---
Before starting Mathematica type,
setenv PRINTER 4 (or whatever 1, 4, 6, 8, 9, etc)
In[1]:= Plot[Sin[x],{x, 0, 2Pi}]
Out[1]= -Graphics-
In[2]:= PSPrint[%]
To save typing `setenv PRINTER 4' each time before you start Mathematica, you can enter the line into your `.cshrc' file. This file is read on login.