Homework 3
Physics 131/231: Simulations in C++
Winter 2000
Problem Set 3
Due 2:00 pm Tuesday, February 1.
All problems from Textbook by Barton and Nackman. You
can download the examples (like Point.h and Point.cc)
in the book from the course home page. Click on "Examples from textbook".
Then download the SciEng.tar file. To unpack the files on a Linux or
unix machine, type "tar -xvf SciEng.tar".
- 2.13 Compare the results of the 2 versions of Stirling formula
(with and without recursion). To see which runs faster, try putting a
loop in main that calls the Stirling function
10,000 times (or less) so that the program takes longer, making it easier
to time. Try both big and small values.
- 4.1 Include the line "Point q[5];" in main (without the quotes)
when you test the program.
- 4.2 (Note: The "moveTo" function changes the coordinates of the point.)
- 4.3
- 4.4 Allow for the fact that some external functions like main may still
need the x and y coordinates, while other external functions may want
the polar coordinates. However, to save space,
only store polar coordinates; don't store both polar and cartesian coordinates.
In all the problems, implement your answers and test them with a simple
program. Show a transcript of what happens when you compile and
run the program in each case.