Starting Mathematica on UNIX

To use Mathematica on UNIX, first source the Mathematica setup file in a SSH program of your choice using the command:
source /usr/usc/math/default/setup.csh
Then type the command math at the UNIX prompt to start Mathematica in text mode or type the command mathematica to start Mathematica with the graphical notebook interface.

Printing or Saving Graphics with Mathematica for UNIX

To print or save graphics output use the Display command to create an output file. Mathematica allows you to generate a number of different output file types. For general use (printing and use in other applications), the encapsulated postscript (EPS) format is recommended. To create an EPS file use the Disiplay command as shown in the following example. When the output of a command is graphics (i.e. Out[9]:= --graphics--), use Display["output.eps", %9, "EPS"] to create the file output.eps in the directory you started Mathematica from. You can then print the postscript file from Mathematica using the command !lpr output.eps (note, the explanation mark (!) acts as a shell escape).

Put and Get Commands (Opening and Saving Files)

To read a file into Mathematica use the Get[" filename "] command or the special input command form << filename. From the UNIX prompt if you invoke Mathematica with the command math -record filename a record of the session will be stored to the file called filename. You can also save an expression definition to a file with the Put[ expr , " filename "] (expr >>filename ) and PutAppend[ expr , " filename "] (expr >>> filename ) commands.

Mathematica Programs (scripts) and Packages

Mathematica also allows you to write scripts and define functions in external text files. All of the commands that we have discussed can by used to write a script with your favorite editor along with other looping and logical operators similar to many programming languages. Mathematica supports a number of packages that are extensions of the main application designed to assist the user in working with a certain group/family of problems. At USC, we have several Mathematica Packages that can found in the directory:

/usr/usc/math/default/AddOns.

Inside this directory you will find several subdirectories that list topics for the packages (PackageName). Inside each of the Mathematica Package directories you will find a number of files with an .m extension. You can load a Mathematica Package file like any other file using the command << PackageName ' filename ' For example, inside the LinearAlgebra package within the StandardPackages directory, there is a routine called Tridiagonal that could be loaded with the command << LinearAlgebra'Tridiagonal'.

Exiting Mathematica for UNIX

To exit Mathematica, type Exit or Quit. After Mathematica begins the prompt will become In[1]:=. For help you can type ? function where function is the name of a command. Mathematica will respond with a short description of the command. For example, ?Log would display information about the natural logarithm command. ??Log would include the description along with a line about the syntax. You can type ? letter(s) * if you are unsure about the name of the command. For example, ?L* would list all of the commands that begin with the letter L. It is important to note that Mathematica commands begin with capital letters.