Name:
CS-220 Spring 2016 Lab 03 Report
1. Cut and paste your final "root" function here...
2. After you added the check to make sure root is not the same as prev_root, you still see messages that
print out "error=0.000000", and the program executes another iteration. How can this be true?
3. By providing tolerance as an argument to your root function, you allow the user to provide a larger
or smaller tolerance. Under what conditions might this feature be important to a user of your root function?
4. Some students have suggested that the tolerance should be specified as a fraction of the original number
instead of as an absolute value. For instance, if the tolerance were 0.001, then the root program would
iterate as long as error > 0.001 * n. Which do you like better... tolerance as an absolute value, or
tolerance as a fraction of the original number? Why?
5. The distance from New York City to Albany, NY is about 150 miles, and the route is approximately North/South.
The distance from Albany, NY to Syracuse NY is about 140 miles, and the route is approximately East/West.
Using your square root program, what is the approximate distance from New York City to Syracuse, assuming
there is a road that follows the hypotenuse of the triangle. (Google Maps says that if you follow the roads,
this will be 247 miles, but that's because the roads aren't straight lines.) How many iterations did you
need to acheive this result?