Problem 953. Pi Estimate 1
Solution Stats
Problem Comments
-
17 Comments
I'll have to say that the checking algorithm is very poorly written. Using isequal instead of an absolute difference with a permitted tolerance check is straight out flawed for me. And after repeating the calculations with both Python and MATLAB. I get an estimate of 3.2323.. for a series of 10 elements (nMax = 10). I wonder how the problem setters arrived at an estimate of 3.04... something. I can't remember the exact value that was used for that test.
So in running this summation through my ti-nspire for 10 iterations, I get an estimate of 3.232323... However, test 1 asserts that this should actually be 3.041840. The code I wrote also returns 3.232323, because it uses the Leibniz formula to estimate pi using the specified number of iterations "nMax". Either I am completely missing something or the author is unaware of what values a correct solution should actually be returning.
Like Sam, my code does not match the 'correct solutions.' As some previous comments suggested, I set my format to long and rounded to six digits.
nMax = 10, my estimate is 3.232316000000000
nMax = 1000, my estimate is 3.142592000000000
nMax = 1e6, my estimate is 3.141594000000000
Solution Comments
Show commentsGroup

Sequences & Series II
- 15 Problems
- 89 Finishers
- Sum of series I
- Largest Geometric Series
- Approximation of Pi
- Sum of series II
- Sum of series III
- Sum of series IV
- Sum of series V
- Sum of series VI
- Sum of series VII
- Generate Square Wave
- Find similar sequences
- Largest Geometric Series
- arithmetic progression
- geometric progression
- Approximation of Pi
- Approximation of Pi (vector inputs)
- Mersenne Primes vs. All Primes
Problem Recent Solvers1218
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!