(a) Write a program to evaluate the particle's position
at times
, where
is some time step. Use double variables to represent all quantities, and use the values
Use a while loop to continue your calculation until
, and
thereby estimate the time
taken for the particle to return to
. Print out this estimate, and compare your result with the
analytic result obtained by solving the appropriate quadratic
equation.
(b) Modify your program to print out the values of
and
(one
pair per line) after every step (don't print out this
output!). Use gpl to plot the trajectory, and verify that the
particle does indeed return to
at the time obtained in part
(a).
For part (a), turn in a printout of your program and the output produced when it runs. For part (b), print out and turn in the (clearly labeled) graph.