One of the benefits of Sage is that you can create dynamic content whether it is an animated GIF or Sage Interactions which can create an object with sliders. Today we'll look at creating an animated GIF that illustrates circular motion. Start the Sage notebook, create a new worksheet, and copy/paste the following code into an empty Sage cell.

t=var('t')
c=parametric_plot((cos(2*t),sin(2*t)), (t,0,pi),color='blue')
L=[]
for i in srange(0,1.57,.01):
L+=[(cos(8*i),sin(8*i))]
d=animate([c+point(L[k], xmin=-2, xmax=2, ymin=-2, ymax=2,color='red', aspect_ratio=1) for k in range(0,157)])
show(d)

Remember, the Python/Sage page has a cheat sheet of commands I put together that can help you as we learn. If we look at the code, the first line defines the variable t. Variables other than x must always be defined. The second line plots the blue circle that our particle will travel around. The third line creates an empty list which will contain the points that our particle will travel on.

The loop:

for i in srange(0,1.57,.01):
L+=[(cos(8*i),sin(8*i))]

calculates the points and adds them to our list. The number 1.57 is approximately . Since the number 1.57 is not plotted, there are now 157 points in our list L. The line

d=animate([c+point(L[k], xmin=-2, xmax=2, ymin=-2, ymax=2,color='red', aspect_ratio=1) for k in range(0,157)])

takes the blue circle (known as c) and plots it along with our list of points, L, on the Cartesian plane specified. The aspect ratio equal to 1 controls makes sure that the x and y units are the same in the picture so that the circle looks like a circle and not an ellipse. This line now draws 157 different pictures of a red dot on each of the 157 different points on a blue circle. The only thing left to do is show us the results; this is the last line of code. Hold down the Shift key while pressing enter and Sage will.....do nothing?!? Not exactly; look at the tab of the browser and you'll see Sage is thinking. It's creating those 157 different pictures and putting them together to form the animated GIF. That takes time. Eventually you'll see the results:

Click on the picture above to get a bigger version and use the magnifying glass to click on the image to get an even larger version.

In the worksheet, you'll see the particle travelling around the circle. To save the animated GIF, right click on the image and select 'Save Image As'. It's worth noting that Python, the language needed in running Sage, requires you to be exact in the indentation. If your code doesn't work this is the place to check.

The animated GIF of circular motion which has been created has been put on a new page: 'Sage Output'. To download the GIF, right click on the image and select 'Save Image As'.