reset password
Author Message
se1k1h1mawar1
Posts: 121
Posted 10:19 Feb 05, 2015 |

I am getting  3.141624 (my cout precision is set to 6) as a result of the run from my lab 3 self-scheduling program at the moment. The number of rectangles is set to 10e5 (uses Riemann Sum, right hand sum, if I did it right).

Does this seem a little off?
How is everybody validating his/her calculation?

Any insights will be greatly appreciated.
Thank you!

Last edited by se1k1h1mawar1 at 10:20 Feb 05, 2015.
gjmiles
Posts: 17
Posted 19:10 Feb 05, 2015 |

This is what I get from 1000000000 rectangles.  I am using 'long double' and parsing an input string which might be a limitation based on the lazy way I am parsing the string which is the atof function.  My number varies from Pi pretty quickly....

3.141592654589793049985796402623350331850815564394

 

se1k1h1mawar1
Posts: 121
Posted 19:34 Feb 05, 2015 |
gjmiles wrote:

This is what I get from 1000000000 rectangles.  I am using 'long double' and parsing an input string which might be a limitation based on the lazy way I am parsing the string which is the atof function.  My number varies from Pi pretty quickly....

3.141592654589793049985796402623350331850815564394

 

Thank you for your reply!
I did not think of using long double.
Your result looks really good!

 

jwarren6
Posts: 56
Posted 01:06 Feb 07, 2015 |

Here's my results:

Number of rectangles? 1000000000
Right pi approximation = 3.1415926525996397552197014757524584638304077088832855
  Left pi approximation = 3.1415926545888162872612742182454326211882289499044418
  Actual approximation = 3.1415926535897932384626433832795028841971693993751058

I used long doubles throughout my program.

Last edited by jwarren6 at 01:07 Feb 07, 2015.