Problem 953. Pi Estimate 1
please update the link to the document, cant find it anymore
The link is broken, but you can solve this problem with the Leibniz formula for π.
The principle is described here: https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80
@Jordan Wilkerson change the number format and round to significant digits shown in test code
Oh right, duh. I should've thought of that haha. That worked! I deleted my last comment since it basically was a solution after all. Thanks for your help!
Leibniz formula, precision 1e-6.
please update the link.
The description has been updated per the link provided in a prior comment.
function [estimate] = pi_est1(nMax)
I believe the task statement should be modified by specifying that the estimate should be rounded. Otherwise, the test suite can be edited accordingly.
The problem description has been updated to specify that rounding is required.
What an idiotic checking algorithm. I spent 10 minutes just trying to get the software to think I had solved the problem when I had already gotten it right multiple times earlier. Make sure you officially round, and not just print it with digits (which is smarter because the variable retains all of its significant digits), otherwise you'll find your time wasted like mine was.
And, all for 10 points. How stupid. Make a better checking algorithm or at least give us more points for having to put up with this BS
I needed to set "format long" to clear the test cases.
The function input is the number of elements in the series for the estimate.
My code worked for tests 1 and 3 perfectly well, but kept getting 3.140592000000000 instead of 3.140593000000000 for test 2.
I tried my answer on Matlab and It is correct but when I wrote it here it shows me wrong.
try round to 6 digit
Problem Recent Solvers610
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
Convert from Fahrenheit to Celsius
More from this Author4
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!