Cody

Solution 1941152

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 = 1 y = 1.000000000000000 0.666666666666667 y = 1.000000000000000 0.666666666666667 0.866666666666667 y = 1.000000000000000 0.666666666666667 0.866666666666667 0.723809523809524 y = 1.000000000000000 0.666666666666667 0.866666666666667 0.723809523809524 0.834920634920635 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 = -0.333333333333333 y = -0.333333333333333 -0.476190476190476 y = -0.333333333333333 -0.476190476190476 -0.567099567099567 y = -0.333333333333333 -0.476190476190476 -0.567099567099567 -0.633766233766234 y = -0.333333333333333 -0.476190476190476 -0.567099567099567 -0.633766233766234 -0.686397812713602 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.111111111111111 y = 0.111111111111111 0.058479532163743 y = 0.111111111111111 0.058479532163743 0.092962290784432 y = 0.111111111111111 0.058479532163743 0.092962290784432 0.067321265143407 y = 0.111111111111111 0.058479532163743 0.092962290784432 0.067321265143407 0.087729428408713 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.052631578947368 y = -0.052631578947368 -0.078272604588394 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 -0.126384356424416 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 -0.126384356424416 -0.133578601028733 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 -0.126384356424416 -0.133578601028733 -0.139867909204833 y = -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 -0.126384356424416 -0.133578601028733 -0.139867909204833 -0.145454501383604 y = Columns 1 through 9 -0.052631578947368 -0.078272604588394 -0.095221757130767 -0.107879984978868 -0.117980995079878 -0.126384356424416 -0.133578601028733 -0.139867909204833 -0.145454501383604 Column 10 -0.150479627011745 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.