Cody

# Problem 953. Pi Estimate 1

Solution 2025287

Submitted on 17 Nov 2019 by Le Duc Vu
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
x = 10; y_correct = 3.041840000000000; assert(isequal(pi_est1(x),y_correct))

x = 1 x = 0.666666666666667 x = 0.866666666666667 x = 0.723809523809524 x = 0.834920634920635 x = 0.744011544011544 x = 0.820934620934621 x = 0.754267954267954 x = 0.813091483679719 x = 0.760459904732351 estimate = 3.041840000000000

2   Pass
x = 1000; y_correct = 3.140593000000000; assert(isequal(pi_est1(x),y_correct))

x = 1 x = 0.666666666666667 x = 0.866666666666667 x = 0.723809523809524 x = 0.834920634920635 x = 0.744011544011544 x = 0.820934620934621 x = 0.754267954267954 x = 0.813091483679719 x = 0.760459904732351 x = 0.808078952351398 x = 0.764600691481833 x = 0.804600691481833 x = 0.767563654444796 x = 0.802046413065486 x = 0.769788348549357 x = 0.800091378852387 x = 0.771519950280959 x = 0.798546977307986 x = 0.772905951666960 x = 0.797296195569399 x = 0.774040381615911 x = 0.796262603838133 x = 0.774986008093452 x = 0.795394171358758 x = 0.775786328221503 x = 0.794654252749805 x = 0.776472434567987 x = 0.794016294217110 x = 0.777067141674737 x = 0.793460584297688 x = 0.777587568424672 x = 0.792972183809287 x = 0.778046810674959 x = 0.792539564298147 x = 0.778455057255894 x = 0.792153687392880 x = 0.778820354059547 x = 0.791807367046560 x = 0.779149139198458 x = 0.791494818210804 x = 0.779446625439720 x = 0.791211331322072 x = 0.779717078448509 x = 0.790953033504689 x = 0.779964022515678 x = 0.790716710687721 x = 0.780190394898247 x = 0.790499673248763 x = 0.780398663147753 x = 0.790299653246763 x = 0.780590915382685 x = 0.790114724906494 x = 0.780768930513971 x = 0.789943242440577 x = 0.780934233431568 x = 0.789783790953691 x = 0.781088138779778 x = 0.789635147326787 x = 0.781231785982249 x = 0.789496248792167 x = 0.781366167491353 x = 0.789366167491353 x = 0.781492151743322 x = 0.789244089727818 x = 0.781610501941559 x = 0.789129298934040 x = 0.781721891526632 x = 0.789021161599625 x = 0.781826916995308 x = 0.788919115576869 x = 0.781926108583862 x = 0.788822660308000 x = 0.782019939219564 x = 0.788731348615538 x = 0.782108832059246 x = 0.788644779771664 x = 0.782193166868439 x = 0.788562593620031 x = 0.782273285443930 x = 0.788484465568154 x = 0.782349496243001 x = 0.788410102303607 x = 0.782422078351511 x = 0.788339238114824 x = 0.782491284898450 x = 0.788271631719260 x = 0.782557346004974 x = 0.788207063519098 x = 0.782620471340327 x = 0.788145333218780 x = 0.782680852344463 x = 0.788086257749869 x = 0.782738664166981 x = 0.788029669457986 x = 0.782794067363745 x = 0.787975414514005 x = 0.782847209385799 x = 0.787923351517779 x = 0.782898225889638 x = 0.787873350267748 x = 0.782947241893364 x = 0.787825290673851 x = 0.782994372799455 x = 0.787779061794671 x = 0.783039725301780 x = 0.787734560982531 x = 0.783083398191833 x = 0.787691693122709 x = 0.783125483077046 x = 0.787650369954874 x = 0.783166065022139 x = 0.787610509466584 x = 0.783205223122971 x = 0.787572035350045 x = 0.783243031021041 x = 0.787534876514603 x = 0.783279557365667 x = 0.787498966648367 x = 0.783314866229957 x = 0.787464243823318 x = 0.783349017485870 x = 0.787430650138931 x = 0.783382067142980 x = 0.787398131400008 x = 0.783414067654988 x = 0.787366636824948 x = 0.783445068197497 x = 0.787336118781155 x = 0.783475114920151 x = 0.787306532544672 x = 0.783504251175851 x = 0.787277836081511 x = 0.783532517729451 x = 0.787249989848411 x = 0.783559952948042 x = 0.787222956611045 x = 0.783586592974682 x = 0.787196701277931 x = 0.783612471887250 x = 0.787171190748460 x = 0.783637621843866 x = 0.787146393773691 x = 0.783662073216199 x = 0.787122280828656 x = 0.783685854711818 x = 0.787098823995094 x = 0.783708993486620 x = 0.787075996853623 x = 0.783731515248272 x = 0.787053774384484 x = 0.783753444351481 x = 0.787032132876071 x = 0.783774803885843 x = 0.787011049840536 x = 0.783795615756934 x = 0.786990503935848 x = 0.783815900761245 x = 0.786970474893737 x = 0.783835678655493 x = 0.786950943453000 x = 0.783854968220802 x = 0.786931891297725 x = 0.783873787322190 x = 0.786913301000002 x = 0.783892152963748 x = 0.786895155966751 x = 0.783910081339885 x = 0.786877440390330 x = 0.783927587882956 x = 0.786860139202604 x = 0.783944687307560 x = 0.786843238032198 x = 0.783961393651794 x = 0.786826723164688 x = 0.783977720315685 x = 0.786810581505487 x = 0.783993680097036 x = 0.786794800545216 x = 0.784009285224881 x = 0.786779368327374 x = 0.784024547390735 x = 0.786764273418133 x = 0.784039477777806 x = 0.786749504878077 x = 0.784054087088319 x = 0.786735052235772 x = 0.784068385569106 x = 0.786720905463005 x = 0.784082383035564 x = 0.786707054951575 x = 0.784096088894133 x = 0.786693491491536 x = 0.784109512163371 x = 0.786680206250774 x = 0.784122661493741 x = 0.786667190755827 x = 0.784135545186207 x = 0.786654436873864 x = 0.784148171209704 x = 0.786641936795739 x = 0.784160547217575 x = 0.786629683020044 x = 0.784172680563042 x = 0.786617668338103 x = 0.784184578313772 x = 0.786605885819825 x = 0.784196247265608 x = 0.786594328800381 x = 0.784207693955512 x = 0.786582990867626 x = 0.784218924673772 x = 0.786571865850243 x = 0.784229945475536 x = 0.786560947806538 x = 0.784240762191689 x = 0.786550231013860 x = 0.784251380439147 x = 0.786539709958598 x = 0.784261805630580 x = 0.786529379326725 x = 0.784272042983610 x = 0.786519233994846 x = 0.784282097529521 x = 0.786509269021726 x = 0.784291974121504 x = 0.786499479640268 x = 0.784301677442466 x = 0.786489861249906 x = 0.784311212012433 x = 0.786480409409396 x = 0.784320582195573 x = 0.786471119829982 x = 0.784329792206856 x = 0.786461988368902 x = 0.784338846118372 x = 0.786453011023234 x = 0.784347747865340 x = 0.786444183924040 x = 0.784356501251806 x = 0.786435503330808 x = 0.784365109956067 x = 0.786426965626170 x = 0.784373577535821 x = 0.786418567310872 x = 0.784381907433072 x = 0.786410304998994 x = 0.784390102978792 x = 0.786402175413400 x = 0.784398167397368 x = 0.786394175381400 x = 0.784406103810823 x = 0.786386301830625 x = 0.784413915242854 x = 0.786378551785094 x = 0.784421604622667 x = 0.786370922361459 x = 0.784429174788643 x = 0.786363410765432 x = 0.784436628491829 x = 0.786356014288375 x = 0.784443968399273 x = 0.786348730304035 x = 0.784451197097204 x = 0.786341556265446 x = 0.784458317094071 x = 0.786334489701951 x = 0.784465330823446 x = 0.786327528216370 x = 0.784472240646797 x = 0.786320669482287 x = 0.784479048856136 x = 0.786313911241457 x = 0.784485757676557 x = 0.786307251301330 x = 0.784492369268662 x = 0.786300687532676 x = 0.784498885730875 x = 0.786294217867320 x = 0.784505309101667 x = 0.786287840295963 x = 0.784511641361682 x = 0.786281552866107 x = 0.784517884435772 x = 0.786275353680060 x = 0.784524040194946 x = 0.786269240893027 x = 0.784530110458244 x = 0.786263212711277 x = 0.784536096994524 x = 0.786257267390393 x = 0.784542001524184 x = 0.786251403233585 x = 0.784547825720809 x = 0.786245618590079 x = 0.784553571212752 x = 0.786239911853561 x = 0.784559239584654 x = 0.786234281460701 x = 0.784564832378898 x = 0.786228725889713 x = 0.784570351097010 x = 0.786223243658993 x = 0.784575797201003 x = 0.786217833325798 x = 0.784581172114669 x = 0.786212493484979 x = 0.784586477224816 x = 0.786207222767766 x = 0.784591713882467 x = 0.786202019840599 x = 0.784596883404002 x = 0.786196883404002 x = 0.784601987072264 x = 0.786191812191501 x = 0.784607026137618 x = 0.786186804968582 x = 0.784612001818975 x = 0.786181860531691 x = 0.784616915304774 x = 0.786176977707270 x = 0.784621767753926 x = 0.786172155350826 x = 0.784626560296730 x = 0.786167392346036 x = 0.784631294035745 x = 0.786162687603892 x = 0.784635970046640 x = 0.786158040061860 x = 0.784640589379008 x = 0.786153448683092 x = 0.784645153057150 x = 0.786148912455646 x = 0.784649662080833 x = 0.786144430391745 x = 0.784654117426022 x = 0.786140001527062 x = 0.784658520045581 x = 0.786135624920027 x = 0.784662870869953 x = 0.786131299651157 x = 0.784667170807819 x = 0.786127024822418 x = 0.784671420746726 x = 0.786122799556596 x = 0.784675621553701 x = 0.786118622996703 x = 0.784679774075839 x = 0.786114494305395 x = 0.784683879140874 x = 0.786110412664412 x = 0.784687937557726 x = 0.786106377274038 x = 0.784691950117037 x = 0.786102387352580 x = 0.784695917591680 x = 0.786098442135859 x = 0.78469984...

3   Pass
x = 1e6; y_correct = 3.141592000000000; assert(isequal(pi_est1(x),y_correct))

x = 1 x = 0.666666666666667 x = 0.866666666666667 x = 0.723809523809524 x = 0.834920634920635 x = 0.744011544011544 x = 0.820934620934621 x = 0.754267954267954 x = 0.813091483679719 x = 0.760459904732351 x = 0.808078952351398 x = 0.764600691481833 x = 0.804600691481833 x = 0.767563654444796 x = 0.802046413065486 x = 0.769788348549357 x = 0.800091378852387 x = 0.771519950280959 x = 0.798546977307986 x = 0.772905951666960 x = 0.797296195569399 x = 0.774040381615911 x = 0.796262603838133 x = 0.774986008093452 x = 0.795394171358758 x = 0.775786328221503 x = 0.794654252749805 x = 0.776472434567987 x = 0.794016294217110 x = 0.777067141674737 x = 0.793460584297688 x = 0.777587568424672 x = 0.792972183809287 x = 0.778046810674959 x = 0.792539564298147 x = 0.778455057255894 x = 0.792153687392880 x = 0.778820354059547 x = 0.791807367046560 x = 0.779149139198458 x = 0.791494818210804 x = 0.779446625439720 x = 0.791211331322072 x = 0.779717078448509 x = 0.790953033504689 x = 0.779964022515678 x = 0.790716710687721 x = 0.780190394898247 x = 0.790499673248763 x = 0.780398663147753 x = 0.790299653246763 x = 0.780590915382685 x = 0.790114724906494 x = 0.780768930513971 x = 0.789943242440577 x = 0.780934233431568 x = 0.789783790953691 x = 0.781088138779778 x = 0.789635147326787 x = 0.781231785982249 x = 0.789496248792167 x = 0.781366167491353 x = 0.789366167491353 x = 0.781492151743322 x = 0.789244089727818 x = 0.781610501941559 x = 0.789129298934040 x = 0.781721891526632 x = 0.789021161599625 x = 0.781826916995308 x = 0.788919115576869 x = 0.781926108583862 x = 0.788822660308000 x = 0.782019939219564 x = 0.788731348615538 x = 0.782108832059246 x = 0.788644779771664 x = 0.782193166868439 x = 0.788562593620031 x = 0.782273285443930 x = 0.788484465568154 x = 0.782349496243001 x = 0.788410102303607 x = 0.782422078351511 x = 0.788339238114824 x = 0.782491284898450 x = 0.788271631719260 x = 0.782557346004974 x = 0.788207063519098 x = 0.782620471340327 x = 0.788145333218780 x = 0.782680852344463 x = 0.788086257749869 x = 0.782738664166981 x = 0.788029669457986 x = 0.782794067363745 x = 0.787975414514005 x = 0.782847209385799 x = 0.787923351517779 x = 0.782898225889638 x = 0.787873350267748 x = 0.782947241893364 x = 0.787825290673851 x = 0.782994372799455 x = 0.787779061794671 x = 0.783039725301780 x = 0.787734560982531 x = 0.783083398191833 x = 0.787691693122709 x = 0.783125483077046 x = 0.787650369954874 x = 0.783166065022139 x = 0.787610509466584 x = 0.783205223122971 x = 0.787572035350045 x = 0.783243031021041 x = 0.787534876514603 x = 0.783279557365667 x = 0.787498966648367 x = 0.783314866229957 x = 0.787464243823318 x = 0.783349017485870 x = 0.787430650138931 x = 0.783382067142980 x = 0.787398131400008 x = 0.783414067654988 x = 0.787366636824948 x = 0.783445068197497 x = 0.787336118781155 x = 0.783475114920151 x = 0.787306532544672 x = 0.783504251175851 x = 0.787277836081511 x = 0.783532517729451 x = 0.787249989848411 x = 0.783559952948042 x = 0.787222956611045 x = 0.783586592974682 x = 0.787196701277931 x = 0.783612471887250 x = 0.787171190748460 x = 0.783637621843866 x = 0.787146393773691 x = 0.783662073216199 x = 0.787122280828656 x = 0.783685854711818 x = 0.787098823995094 x = 0.783708993486620 x = 0.787075996853623 x = 0.783731515248272 x = 0.787053774384484 x = 0.783753444351481 x = 0.787032132876071 x = 0.783774803885843 x = 0.787011049840536 x = 0.783795615756934 x = 0.786990503935848 x = 0.783815900761245 x = 0.786970474893737 x = 0.783835678655493 x = 0.786950943453000 x = 0.783854968220802 x = 0.786931891297725 x = 0.783873787322190 x = 0.786913301000002 x = 0.783892152963748 x = 0.786895155966751 x = 0.783910081339885 x = 0.786877440390330 x = 0.783927587882956 x = 0.786860139202604 x = 0.783944687307560 x = 0.786843238032198 x = 0.783961393651794 x = 0.786826723164688 x = 0.783977720315685 x = 0.786810581505487 x = 0.783993680097036 x = 0.786794800545216 x = 0.784009285224881 x = 0.786779368327374 x = 0.784024547390735 x = 0.786764273418133 x = 0.784039477777806 x = 0.786749504878077 x = 0.784054087088319 x = 0.786735052235772 x = 0.784068385569106 x = 0.786720905463005 x = 0.784082383035564 x = 0.786707054951575 x = 0.784096088894133 x = 0.786693491491536 x = 0.784109512163371 x = 0.786680206250774 x = 0.784122661493741 x = 0.786667190755827 x = 0.784135545186207 x = 0.786654436873864 x = 0.784148171209704 x = 0.786641936795739 x = 0.784160547217575 x = 0.786629683020044 x = 0.784172680563042 x = 0.786617668338103 x = 0.784184578313772 x = 0.786605885819825 x = 0.784196247265608 x = 0.786594328800381 x = 0.784207693955512 x = 0.786582990867626 x = 0.784218924673772 x = 0.786571865850243 x = 0.784229945475536 x = 0.786560947806538 x = 0.784240762191689 x = 0.786550231013860 x = 0.784251380439147 x = 0.786539709958598 x = 0.784261805630580 x = 0.786529379326725 x = 0.784272042983610 x = 0.786519233994846 x = 0.784282097529521 x = 0.786509269021726 x = 0.784291974121504 x = 0.786499479640268 x = 0.784301677442466 x = 0.786489861249906 x = 0.784311212012433 x = 0.786480409409396 x = 0.784320582195573 x = 0.786471119829982 x = 0.784329792206856 x = 0.786461988368902 x = 0.784338846118372 x = 0.786453011023234 x = 0.784347747865340 x = 0.786444183924040 x = 0.784356501251806 x = 0.786435503330808 x = 0.784365109956067 x = 0.786426965626170 x = 0.784373577535821 x = 0.786418567310872 x = 0.784381907433072 x = 0.786410304998994 x = 0.784390102978792 x = 0.786402175413400 x = 0.784398167397368 x = 0.786394175381400 x = 0.784406103810823 x = 0.786386301830625 x = 0.784413915242854 x = 0.786378551785094 x = 0.784421604622667 x = 0.786370922361459 x = 0.784429174788643 x = 0.786363410765432 x = 0.784436628491829 x = 0.786356014288375 x = 0.784443968399273 x = 0.786348730304035 x = 0.784451197097204 x = 0.786341556265446 x = 0.784458317094071 x = 0.786334489701951 x = 0.784465330823446 x = 0.786327528216370 x = 0.784472240646797 x = 0.786320669482287 x = 0.784479048856136 x = 0.786313911241457 x = 0.784485757676557 x = 0.786307251301330 x = 0.784492369268662 x = 0.786300687532676 x = 0.784498885730875 x = 0.786294217867320 x = 0.784505309101667 x = 0.786287840295963 x = 0.784511641361682 x = 0.786281552866107 x = 0.784517884435772 x = 0.786275353680060 x = 0.784524040194946 x = 0.786269240893027 x = 0.784530110458244 x = 0.786263212711277 x = 0.784536096994524 x = 0.786257267390393 x = 0.784542001524184 x = 0.786251403233585 x = 0.784547825720809 x = 0.786245618590079 x = 0.784553571212752 x = 0.786239911853561 x = 0.784559239584654 x = 0.786234281460701 x = 0.784564832378898 x = 0.786228725889713 x = 0.784570351097010 x = 0.786223243658993 x = 0.784575797201003 x = 0.786217833325798 x = 0.784581172114669 x = 0.786212493484979 x = 0.784586477224816 x = 0.786207222767766 x = 0.784591713882467 x = 0.786202019840599 x = 0.784596883404002 x = 0.786196883404002 x = 0.784601987072264 x = 0.786191812191501 x = 0.784607026137618 x = 0.786186804968582 x = 0.784612001818975 x = 0.786181860531691 x = 0.784616915304774 x = 0.786176977707270 x = 0.784621767753926 x = 0.786172155350826 x = 0.784626560296730 x = 0.786167392346036 x = 0.784631294035745 x = 0.786162687603892 x = 0.784635970046640 x = 0.786158040061860 x = 0.784640589379008 x = 0.786153448683092 x = 0.784645153057150 x = 0.786148912455646 x = 0.784649662080833 x = 0.786144430391745 x = 0.784654117426022 x = 0.786140001527062 x = 0.784658520045581 x = 0.786135624920027 x = 0.784662870869953 x = 0.786131299651157 x = 0.784667170807819 x = 0.786127024822418 x = 0.784671420746726 x = 0.786122799556596 x = 0.784675621553701 x = 0.786118622996703 x = 0.784679774075839 x = 0.786114494305395 x = 0.784683879140874 x = 0.786110412664412 x = 0.784687937557726 x = 0.786106377274038 x = 0.784691950117037 x = 0.786102387352580 x = 0.784695917591680 x = 0.786098442135859 x = 0.78469984...