CS 108: Introduction to Computing Spring 2006 |
|||||||
Project #5 |
|||||||
The ProjectPrepare for the project by following the general instructions for Project #5. I've always felt very bad for William Shanks (as described in our videos) who spent over twenty years of his life trying to compute pi to 707 decimal places, only to make a mistake on digit 528. It's especially tragic because our computers can compute pi correctly to the same number of digits in a heartbeat. So the goal of this project is to emphasize the tragedy of William Shanks. The SetupThe purpose of your program is to experiment with pi computations. So getting the right answer is less important than discovering interesting properties about the computations. Consequently, you will have no unit tests for this assignment, but instead you will run a driver several times to discover the interesting properties. Start with these methods in
public static void main(String[] args) { Screen theScreen = new Screen(); Keyboard theKeyboard = new Keyboard(); theScreen.print("Enter the number of iterations: "); int iterations = theKeyboard.readInt(); PiCalculationsCLIDriver.report("Indiana-State-Senate technique", PiCalculations.indiana(iterations)); // repeat the previous line, once for each method in PiCalculations } private static void report(String techniqueName, BigDecimal valueForPi) { Screen theScreen = new Screen(); theScreen.println(techniqueName + " reports " + valueForPi + " as the value for pi."); } You will also need this method in
public static BigDecimal indiana(int iterations) { return new BigDecimal("4.0"); } The Modify this code in the following ways:
Write up an OCD for one of your computations. Indicate a source for each of the computations that you implement in this same design document. The ExperimentsThe goal of this project is to find the number of iterations each technique requires to get an accuracy of 707 digits. That is, the absolute value of the difference should be less than 10-707. You have to figure this out for yourself by running the driver over and over again with a different number of iterations each time. However, it appears that many techniques get nowhere close to this kind of accuracy in Java in a reasonable amount of time. If a particular computation takes longer than five minutes, reduce the number of iterations until you find a number that takes about five minutes. In your design document (along with your OCD), add a section where you list the techniques you employed. For each technique, report one of two things:
|
|||||||
|