## Mathematica Tutorial

What is Mathematica?

Mathematica is a product of Wolfram Research, Inc.

Mathematica is a software system and computer language for use in mathematical applications. The three classes of Mathematica computations are: numerical, symbolic, and graphical. Mathematica can

• be used as a calculator with a much higher degree of precision than tradi tional calculators
• perform operations on functions, manipulate algebraic formulas, and do calculus
• produce both two- and three- dimensional graphs
• support its own high-level pro gramming language

The Basics

Mathematica can run in either an ASCII terminal mode or as an X-window System client. To run Mathematica from an ASCII terminal, enter math. To run Mathematica as an X-window System client, enter mathematica.

Numerical Calculations

Arithmetic can be performed in Mathematica just as on a calculator. In this example, you would have typed 2 + 6 and then pressed [SHIFT-RETURN].

In[1]:=
2 + 6
Out[1]:=
8
Variable Definition

In order to assign a specific value to a variable, simply tell Mathematica what you would like to name the variable and what value it should be assigned.

In[1]:=
x = 2
Out[1]=
2

This action defines the variable x to have the value. 2. This value assignment is permanent until you remove it, or start a new Mathematica session.

Having assigned a value to x, you can now use x in further equations without having to ever type x's value.

For example:

In[1]:=
x ^ 3
Out[1]=
8

Summations and Products

Mathematica will handle summations and products easily. The notation is intuitive. For a simple product, the notation would be Sum[f, {i, imin, imax}]. For example,

In[2]:=
Sum[x/Pi^i, {i, 1, 5}]

Out[2]=
 x x x x x --- + --- + --- + --- + --- Pi5 Pi4 Pi3 Pi2 Pi1

Two-Dimensional Plotting

Mathematica uses the Plot command to produce 2-D plots. You basically specify the equation to be plotted followed by a list that contains the variable and min and max values for a range. The statements usually look like this, Plot[f[x], {x, xmin, xmax}]. For example, here is a simple parabola:

In[1]:=
Plot[(3*x^2 - 4), {x, -10, 10}];

Three-Dimensional Plotting

It is quite easy (and fun) to plot in three dimensions. The format is similar to above. One just uses the Plot3D command:

In[11]:=
Plot3D[(x^3) * Sin[a*x^2], {a,0,5},{x,0,3}];

Animations

Mathematica can also produce animation of plots via a simple Do loop. This way you can see how a plot can vary over different conditions. Below is an animation of the Cosine function

In[11]:=
Do[Plot[Cos[n*x], {x, 0, 2Pi}],
{n, 1, 2, 0.2}];

[an error occurred while processing this directive]