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

Strings II
- 21 Problems
- 41 Finishers
- Find the sum of all the numbers of the input vector
- Select every other element of a vector
- Arrange Vector in descending order
- Inner product of two vectors
- Get the length of a given vector
- Find max
- Whether the input is vector?
- Flip the vector from right to left
- Create a vector
- Doubling elements in a vector
- Vector creation
Problem Recent Solvers1215
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!