Cody

Solution 1941138

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

a = 1 y = 4 a = 0.666666666666667 y = 4.000000000000000 2.666666666666667 a = 0.866666666666667 y = 4.000000000000000 2.666666666666667 3.466666666666667 a = 0.723809523809524 y = 4.000000000000000 2.666666666666667 3.466666666666667 2.895238095238096 a = 0.834920634920635 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

a = -0.333333333333333 y = -1.333333333333333 a = -0.133333333333333 y = -1.333333333333333 -0.533333333333333 a = -0.276190476190476 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 a = -0.165079365079365 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 a = -0.255988455988456 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 -1.023953823953824 a = -0.179065379065379 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 -1.023953823953824 -0.716261516261516 a = -0.245732045732046 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 -1.023953823953824 -0.716261516261516 -0.982928182928183 a = -0.186908516320281 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 -1.023953823953824 -0.716261516261516 -0.982928182928183 -0.747634065281124 a = -0.239540095267649 y = -1.333333333333333 -0.533333333333333 -1.104761904761905 -0.660317460317460 -1.023953823953824 -0.716261516261516 -0.982928182928183 -0.747634065281124 -0.958160381070598 y = 4.474925986923126 3.674925986923126 4.246354558351698 3.801910113907253 4.165546477543617 3.857854169851310 4.124520836517976 3.889226718870917 4.099753034660391

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

a = 0.111111111111111 y = 0.444444444444444 a = 0.020202020202020 y = 0.444444444444444 0.080808080808081 a = 0.097125097125097 y = 0.444444444444444 0.080808080808081 0.388500388500388 a = 0.030458430458430 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 a = 0.089281959870195 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 a = 0.036650380922827 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 a = 0.084269428541874 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 a = 0.040791167672309 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 a = 0.080791167672309 y = 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 a = 0.043754130635272 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Column 10 0.175016522541088 a = 0.078236889255962 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 11 0.175016522541088 0.312947557023847 a = 0.045978824739833 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 12 0.175016522541088 0.312947557023847 0.183915298959331 a = 0.076281855042863 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 13 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 a = 0.047710426471434 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 14 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 a = 0.074737453498462 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 15 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 a = 0.049096427857436 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 16 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 a = 0.073486671759875 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 17 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 0.293946687039500 a = 0.050230857806387 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 18 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 0.293946687039500 0.200923431225546 a = 0.072453080028609 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 18 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 0.293946687039500 0.200923431225546 Column 19 0.289812320114435 a = 0.051176484283928 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 18 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 0.293946687039500 0.200923431225546 Columns 19 through 20 0.289812320114435 0.204705937135712 a = 0.071584647549234 y = Columns 1 through 9 0.444444444444444 0.080808080808081 0.388500388500388 0.121833721833722 0.357127839480781 0.146601523691307 0.337077714167497 0.163164670689237 0.323164670689237 Columns 10 through 18 0.175016522541088 0.312947557023847 0.183915298959331 0.305127420171452 0.190841705885738 0.298949813993846 0.196385711429743 0.293946687039500 0.200923431225546 Columns 19 through 21 0.289812320114435 0.204705937135712 0.286338590196936 y = Columns 1 through 9 2.697148209145348 3.060784572781712 2.753092265089405 3.019758931756071 2.784464814109012 2.994991129898486 2.804514939422296 2.978427982900556 2.818427982900556 Columns 10 through 18 2.966576131048705 2.828645096565946 2.957677354630462 2.836465233418341 2.950750947704055 2.842642839595947 2.945206942160050 2.847645966550294 2.940669222364247 Columns 19 through 21 2.851780333475358 2.936886716454082 2.855254063392857

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

a = -0.052631578947368 y = -0.210526315789474 a = -0.005012531328321 y = -0.210526315789474 -0.020050125313283 a = -0.048490792197886 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 a = -0.008490792197886 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 a = -0.045527829234923 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 a = -0.011045070614233 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 a = -0.043303135130362 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 a = -0.013000104827332 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 a = -0.041571533398761 y = -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 a = -0.014544506371734 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Column 10 -0.058178025486935 a = -0.040185532012759 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 11 -0.058178025486935 -0.160742128051037 a = -0.015795288110320 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 12 -0.058178025486935 -0.160742128051037 -0.063181152441281 a = -0.039051102063809 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 13 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 a = -0.016828879841586 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 14 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 a = -0.038105475586267 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 15 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 a = -0.017697312320961 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 16 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 a = -0.037305155458216 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 17 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 a = -0.018437230929914 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 a = -0.036619049111732 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Column 19 -0.146476196446929 a = -0.019075189462610 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 20 -0.146476196446929 -0.076300757850438 a = -0.036024342004982 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 21 -0.146476196446929 -0.076300757850438 -0.144097368019930 a = -0.019630899382032 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 22 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 a = -0.035503915255047 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 23 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 -0.142015661020190 a = -0.020119299870432 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 24 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 -0.142015661020190 -0.080477199481728 a = -0.035044673004760 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 25 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 -0.142015661020190 -0.080477199481728 -0.140178692019042 a = -0.020551919381572 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 26 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 -0.142015661020190 -0.080477199481728 -0.140178692019042 -0.082207677526288 a = -0.034636426423826 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.067315519366346 -0.152421902345069 -0.070789249283845 -0.149220621832864 -0.073748923719657 Columns 19 through 27 -0.146476196446929 -0.076300757850438 -0.144097368019930 -0.078523597528126 -0.142015661020190 -0.080477199481728 -0.140178692019042 -0.082207677526288 -0.138545705695302 a = -0.020937796286839 y = Columns 1 through 9 -0.210526315789474 -0.020050125313283 -0.193963168791544 -0.033963168791544 -0.182111316939692 -0.044180282456934 -0.173212540521450 -0.052000419309328 -0.166286133595043 Columns 10 through 18 -0.058178025486935 -0.160742128051037 -0.063181152441281 -0.156204408255235 -0.0...

Assertion failed.