Cody

Solution 1941146

Submitted on 18 Sep 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 1:5; y_correct = [-0.858407346410207 0.474925986923126 -0.325074013076874 0.246354558351698 -0.198089886092747]; answers = pi_approx(n); for i = 1:numel(n) assert(abs(answers(i)-y_correct(i))<(100*eps)) end

y = 4 y = 4.000000000000000 2.666666666666667 y = 4.000000000000000 2.666666666666667 3.466666666666667 y = 4.000000000000000 2.666666666666667 3.466666666666667 2.895238095238096 y = 4.000000000000000 2.666666666666667 3.466666666666667 2.895238095238096 3.339682539682540 y = -0.858407346410207 0.474925986923126 -0.325074013076874 0.246354558351698 -0.198089886092747

2   Fail
n = 2:2:10; y_correct = [0.474925986923126 0.246354558351698 0.165546477543617 0.124520836517975 0.099753034660390]; answers = pi_approx(n); for i = 1:numel(n) assert(abs(answers(i)-y_correct(i))<(100*eps)) end

y = -1.333333333333333 y = -1.333333333333333 -1.904761904761905 y = -1.333333333333333 -1.904761904761905 -2.268398268398268 y = -1.333333333333333 -1.904761904761905 -2.268398268398268 -2.535064935064935 y = -1.333333333333333 -1.904761904761905 -2.268398268398268 -2.535064935064935 -2.745591250854408 y = 4.474925986923126 5.046354558351698 5.409990921988062 5.676657588654728 5.887183904444202

Assertion failed.

3   Fail
n = 5:5:25; y_correct = [-0.198089886092747 0.099753034660390 -0.066592998672151 0.049968846921953 -0.039984031845239]; answers = pi_approx(n); for i = 1:numel(n) assert(abs(answers(i)-y_correct(i))<(100*eps)) end

y = 0.444444444444444 y = 0.444444444444444 0.233918128654971 y = 0.444444444444444 0.233918128654971 0.371849163137729 y = 0.444444444444444 0.233918128654971 0.371849163137729 0.269285060573627 y = 0.444444444444444 0.233918128654971 0.371849163137729 0.269285060573627 0.350917713634851 y = 2.697148209145348 2.907674524934822 2.769743490452064 2.872307593016166 2.790674939954942

Assertion failed.

4   Fail
n = 10:10:100; y_correct = [0.099753034660390 0.049968846921953 0.033324086890846 0.024996096795960 0.019998000998782 0.016665509660796 0.014284985608559 0.012499511814072 0.011110768228485 0.009999750031239]; answers = pi_approx(n); for i = 1:numel(n) assert(abs(answers(i)-y_correct(i))<(100*eps)) end

y = -0.210526315789474 y = -0.210526315789474 -0.313090418353576 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 -0.505537425697664 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 -0.505537425697664 -0.534314404114931 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 -0.505537425697664 -0.534314404114931 -0.559471636819333 y = -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 -0.505537425697664 -0.534314404114931 -0.559471636819333 -0.581818005534417 y = Columns 1 through 9 -0.210526315789474 -0.313090418353576 -0.380887028523068 -0.431519939915473 -0.471923980319513 -0.505537425697664 -0.534314404114931 -0.559471636819333 -0.581818005534417 Column 10 -0.601918508046980 y = Columns 1 through 9 3.352118969379267 3.454683071943369 3.522479682112861 3.573112593505266 3.613516633909306 3.647130079287458 3.675907057704724 3.701064290409126 3.723410659124210 Column 10 3.743511161636773

Assertion failed.

Suggested Problems

More from this Author139