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

Project Euler II
- 12 Problems
- 51 Finishers
- Find the longest sequence of 1's in a binary sequence.
- Convert given decimal number to binary number.
- Find out sum and carry of Binary adder
- Binary numbers
- Given an unsigned integer x, find the largest y by rearranging the bits in x
- Bit Reversal
- Relative ratio of "1" in binary number
- Binary code (array)
- Converting binary to decimals
- There are 10 types of people in the world
Problem Recent Solvers1217
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!