## A simple example for creating animated GIF files within Mathematica on the Silicon Graphics in the Visualization Lab (Burton Hall 302)

Initial setup: We will create an animated GIF file displaying a family of degree 3 polynomials. We will vary the coefficients a and b of the polynomial p:

```      In[1]:=
p = x^3 + a x+ b;              a = Cos[t];              b = Sin[t];              graph := Plot[p,{x,-2,2},PlotRange->{{-2,2},{-6,6}}];```
To create a plot of the graph, we choose a specific value for t and call upon graph; for instance:

`     In[5]:=  t = 2.2; graph;`

`          `

The following command creates a single GIF file with the name "graphPoly.gif". This file is placed in the directory where Mathematica is running:

```     In[6]:=  Display["graphPoly.gif",graph,"GIF"]
```
The following Do-loop creates 20 GIF files with the names pic.11, pic.12,...., pic.30. These are the individual frames of the animation. We take 20 values for t within the interval [0,2 pi]. We chose these filenames (instead of pic.1, pic.2,..., pic.20 or 1.gif, 2.gif,..., 20.gif) because of the lexicographical order unix uses to save files. We DO NOT want to change the order in which the frames are shown in the animation! Notice that we need to convert the value of the numbers 10+k into a string of characters (with ToString) and then join this to "pic." (with StringJoin).

```     In[7]:=
Do[ t = k (2Pi/20);                  Display[StringJoin["pic.",ToString[10+k]],graph,"GIF"],               {k,1,20}];```

`         `

The following command will run the program "convert" outside Mathematica. It creates an animated GIF file named "CubicPolys.gif". The "delay" flag controls the delay time between frames. The "loop" flag tells the browser how many times to run the animation loop:

```     In[8]:=  !convert -delay 20 -loop 10 pic* CubicPolys.gif
```
The animated file "CubicPolys.gif" can be incorporated into an HTML document. For instance, with the line:
<img src="CubicPolys.gif">

You can remove (delete) the 20 files pic.* with the following:

`     In[9]:=  !rm -f pic.*`