We often ask a computer to do an operation many times. There are a large number of ways of doing these ``iterative''tasks in Mathematica. Here are two that you will need this week(look them up in the online help):
You will also need to learn how to plot lists of numbers using:
Finally, animation is
very simple in mathematica. Simply generate a series of
frames (e.g. using a ``Do'' loop) and then double click on one of the
frames. This automatically animates the set of frames.
Problem 1. (i) Listplot plots a list of numbers on the y axis of a graph. To see how this works, enter the following code
(ii) Three dimensional plots are just as easy. Enter and run the following code
(iii) Using the Table function, generate
points to represent a circle for y>0. Plot this data using
Here is a code to sum the first n integers, with n running
from 1 to 100. The first command sets up an array which
is used to store the sums.
The Riemann zeta function is defined by
sum is convergent for p>1(why?). Write a program
to find as a function of the number of terms, N, included
in the sum. Plot
the value of this sum for p=3 as a function of N. How many
terms do you need to take until your answer appears
to be correct to 4 digit accuracy(how big does N need to be)?
Enter and run the following code which animates
timestep = 0.1 Pi
tstart = 0
tend = timestep
Modify this code to animate the following projectile motion problem: A mass of 20kg is fired from a height of 2000 meters, with initial angle to the horizontal of 60 degrees and initial speed of 500m/s (ignore drag). Your animation should begin at firing and end when the mass hits ground level. DO NOT print out the frames used to produce your animation. Instead show your animation to your TA. However DO hand in your Mathematica code.