### Department of Physics & Astronomy

Courses
Events
Research
People
Facilities

Main Page
SFSU Home
• Computer System
• Mathematica Tutorial

### Mathematica Tutorial for the Physics and Astronomy Department

This is a very short tutorial in using the Steven Wolfram program Mathematica. The object is to help a user of the P&A computer system start using this program. Complete information about mathematica is supplied by the progam itself - Wolfram's 2000-page book Mathematica is included as part of the online help!

To start, log onto the Unix machine hodge, from a terminal which supports graphics. You may have to set the environmental variable DISPLAY to the IP address of the machine you are on, e.g.:

Start Mathematica:
After a while you should have a new window for input to Mathematica. If you get an error message about not being able to open the display, refer to Remote Graphics Configuration.

Make sure that NUMLOCK is set on your keyboard -- keyboard input may not work without it.
Type in:

4*5
Note that if you press return, nothing happens. To cause the instruction to be carried out, press either the enter key on the keypad, or shift return. Can you guess what the answer will be? Notice how long it takes Mathematica to figure it out. This is the program that launched a thousand ships? (To be fair, the time elapsed is required to load the Mathematica kernel into memory. It will be a little faster from now on.)

Now try a graph:

Plot[Sin[x],{x,0,3Pi}]
Did you get a graph? If so, you're done!

Here's an example of how to solve a set of linear equations:

In[4]:=  Solve[{a*x+b*y==1,c*x+d*y==5}, {x,y}]

5b-d            -5a+c
Out[4] = {{x-> - _______, y -> - _______