*************************
COSC 235 - Assignment #3
*************************
TASK: Write a Python program that:
1) Asks the user for an integer greater than or equal to 0
2) Computes an approximation of 'pi' by summing the terms of the series 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...
3) The value given by the user will tell your program how many terms of the series to use
- For example, if the user gives you a '3', then sum the first three values (4/1 - 4/3 + 4/5)
4) Your program should work with any given integer input greater than or equal to 0
5) Displays the *absolute error* (how much your approximation was actually off by) and the *relative error* (a measure of
how much your approximation was off by relative to the size of the numbers being used) of your approximation
by using the following formulas (note the absolute value bars):
absoluteError = |approximatedValue - actualValue|
relativeError = absoluteError / |actualValue|
6) Use math.pi from the math library as the actualValue
7) The relative error will compute as a floating-point number, but you should also display it as a percentage with only
3 decimal places visible (you should round it)
EXAMPLE: An example run of the program might look like this (but test it with multiple inputs!)
===================================================
Please enter an integer greater than or equal to 0: 3
approximated value of pi: 3.466666666666667
actual value of pi: 3.141592653589793
absolute error: 0.32507401307687367
relative error: 0.10347427210380775 (10.347 %)
===================================================
DOCUMENT: You should also document/comment your code. At the top of your source code file, give a description of the program, the author of the code, and the date the code was written. Also place comments throughout your program (you can decide when you have enough comments).
SUBMIT: Save your program as 'pi.py', and submit it on Moodle by Friday, March 3rd (11:59PM).