Introduction to Mathematica

Getting Started

To open Mathematica, double click on the Mathematica icon on the left of the screen.  This will start a new document called "Untitled-1".  I suggest you start by typing a simple expression like

2+2

then hit the "enter" key to the right of the number pad or hit "shift" and "enter" simultaneously on the main keyboard.  This first command may take a few seconds to execute. If you hit the correct key, Mathematica should display:

2+2

The purpose is to ensure Mathematica is running properly.  Now try graphing a simple function.

Plot[Sin[x],{x,-3π, 3π}]

In order to enter π, you may click on the "pi" button on the palette or simply type Pi.  After pressing enter you should get:

Plot[Sin[x],{x, -3π,3π}]

Common Mistakes

As you may have noticed, Mathematica defined functions are typically capitalized.  If you accidentally type sin[x] for Sin[x] you will see:

Plot[sin[x], {x, -3π, 3π}]

Mathematica will try to warn you that you have misspelled something.  Similar error messages occur if you leave out a bracket or misuse  "(" for "[".

Plot[Sin[x],{x, -3*Pi, 3*Pi]

Defining Functions

We can define functions to save time.  The "Clear[f]" command just makes sure the function "f" has not been previously defined.

Clear[f];
f[x_]:=Cos[2x^2]

The underscore tells Mathematica that "x" is the variable.  The := means "defined to be equal to". And we can express exponents using the palette buttons or a "^" like you may use on your calculators.

	Now try computing f(0).

f[0]

So, this tells us the f(0)=1 -- which is easy to check.

Additional Information

Commands

Some quick commands via examples.

Log[2,8]

This was (Subscript[log, 2])(8).  If you omit the two arguments and just type Log[x] Mathematica interprets this as a natural log.

Integrate[x^2,x]

D[x^5,x]

Expand[(2x^3+x^2-1)(x^2-9)]

Simplify[x^2+2x+1]

These are only a few of the many powerful built-in Mathematica commands.  Try playing around and see if you can find new commands that may be helpful to you.

Multiplication

You need to be careful with multiplication for Mathematica. The expression x + y + xy, common to us all, would be misinterpreted as  three variable x, y  and xy, rather than x*y.  If you want multiplication between variables, you must use the "*" to indicate multiplication or leave a space.

Style

This document was written in Mathematica.  In order to type text versus Mathematica input (the bold-faced type with the numbered In and Out preceding them) I needed to select a text option from the "Format" option on the menu bar. I then went to "Style" and could select various kind of type.  I encourage you to experiment with this so that your printed homework is clearly labelled and easy to follow.

Saving your work

It is important to work from the hard disk and to save your work.  You must either save it to your account (which keeps it private) or save it to the MathCS Hold Folder(4 Days) if you want it to be public. Once you save it you can then copy it to your disk.  However, if you try saving directly to your disk or working from your disk, you run the risk of crashing the computer and losing everything.

Learning Mathematica commands

The easiest way to explore Mathematica commands if to use the help browser which is available on the menu bar.  All the commands and their syntax is explained often with examples.  I encourage you to give this a try! Also, you will receive a card with some of the basic commands -- please hang on to this throughout the term.