Cody

Problem 837. Find all the zeros of sinus , cosinus and tangent in a given interval

Solution 2457779

Submitted on 2 Jun 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Fail
assert(all(abs(find_zeros(@sin,0,2*pi) -[0 pi 2*pi])<1e-9)) %[0 pi] assert(all(abs(find_zeros(@sin,0,pi) -[0 pi ])<1e-9)) % [0 pi/3] assert(all(abs(find_zeros(@sin,0,pi/3) -0) <1e-9))

ans = Columns 1 through 9 0 -0.000007346410207 -0.000107346410001 -0.000207346408721 -0.000307346405368 -0.000407346398941 -0.000507346388442 -0.000607346372868 -0.000707346351221 Columns 10 through 18 -0.000807346322501 -0.000907346285707 -0.001007346239840 -0.001107346183899 -0.001207346116885 -0.001307346037797 -0.001407345945636 -0.001507345839402 -0.001607345718093 Columns 19 through 27 -0.001707345580712 -0.001807345426257 -0.001907345253729 -0.002007345062127 -0.002107344850451 -0.002207344617703 -0.002307344362881 -0.002407344084985 -0.002507343783016 Columns 28 through 36 -0.002607343455973 -0.002707343102857 -0.002807342722668 -0.002907342314405 -0.003007341877069 -0.003107341409659 -0.003207340911176 -0.003307340380620 -0.003407339816990 Columns 37 through 45 -0.003507339219286 -0.003607338586510 -0.003707337917660 -0.003807337211736 -0.003907336467740 -0.004007335684669 -0.004107334861526 -0.004207333997309 -0.004307333091019 Columns 46 through 54 -0.004407332141655 -0.004507331148218 -0.004607330109708 -0.004707329025125 -0.004807327893468 -0.004907326713738 -0.005007325484934 -0.005107324206058 -0.005207322876108 Columns 55 through 63 -0.005307321494085 -0.005407320058989 -0.005507318569819 -0.005607317025577 -0.005707315425261 -0.005807313767872 -0.005907312052410 -0.006007310277875 -0.006107308443266 Columns 64 through 72 -0.006207306547585 -0.006307304589830 -0.006407302569003 -0.006507300484102 -0.006607298334129 -0.006707296118082 -0.006807293834963 -0.006907291483770 -0.007007289063505 Columns 73 through 81 -0.007107286573166 -0.007207284011756 -0.007307281378271 -0.007407278671715 -0.007507275891085 -0.007607273035383 -0.007707270103608 -0.007807267094760 -0.007907264007840 Columns 82 through 90 -0.008007260841847 -0.008107257595781 -0.008207254268643 -0.008307250859432 -0.008407247367149 -0.008507243790793 -0.008607240129365 -0.008707236381864 -0.008807232547291 Columns 91 through 99 -0.008907228624646 -0.009007224612928 -0.009107220511139 -0.009207216318276 -0.009307212033342 -0.009407207655336 -0.009507203183258 -0.009607198616107 -0.009707193952885 Columns 100 through 108 -0.009807189192591 -0.009907184334224 -0.010007179376786 -0.010107174319276 -0.010207169160695 -0.010307163900041 -0.010407158536316 -0.010507153068520 -0.010607147495652 Columns 109 through 117 -0.010707141816712 -0.010807136030701 -0.010907130136619 -0.011007124133465 -0.011107118020240 -0.011207111795944 -0.011307105459577 -0.011407099010139 -0.011507092446630 Columns 118 through 126 -0.011607085768050 -0.011707078973398 -0.011807072061677 -0.011907065031885 -0.012007057883021 -0.012107050614088 -0.012207043224083 -0.012307035712009 -0.012407028076864 Columns 127 through 135 -0.012507020317648 -0.012607012433363 -0.012707004423007 -0.012806996285581 -0.012906988020086 -0.013006979625520 -0.013106971100885 -0.013206962445180 -0.013306953657405 Columns 136 through 144 -0.013406944736561 -0.013506935681648 -0.013606926491664 -0.013706917165612 -0.013806907702491 -0.013906898101300 -0.014006888361041 -0.014106878480713 -0.014206868459316 Columns 145 through 153 -0.014306858295850 -0.014406847989315 -0.014506837538712 -0.014606826943041 -0.014706816201301 -0.014806805312494 -0.014906794275618 -0.015006783089674 -0.015106771753663 Columns 154 through 162 -0.015206760266584 -0.015306748627437 -0.015406736835222 -0.015506724888941 -0.015606712787592 -0.015706700530175 -0.015806688115693 -0.015906675543143 -0.016006662811526 Columns 163 through 171 -0.016106649919843 -0.016206636867093 -0.016306623652277 -0.016406610274394 -0.016506596732446 -0.016606583025431 -0.016706569152351 -0.016806555112204 -0.016906540903993 Columns 172 through 180 -0.017006526526716 -0.017106511979374 -0.017206497260966 -0.017306482370494 -0.017406467306957 -0.017506452069355 -0.017606436656688 -0.017706421067958 -0.017806405302163 Columns 181 through 189 -0.017906389358304 -0.018006373235381 -0.018106356932394 -0.018206340448344 -0.018306323782230 -0.018406306933054 -0.018506289899814 -0.018606272681511 -0.018706255277145 Columns 190 through 198 -0.018806237685717 -0.018906219906227 -0.019006201937674 -0.019106183779059 -0.019206165429383 -0.019306146887645 -0.019406128152845 -0.019506109223984 -0.019606090100062 Columns 199 through 207 -0.019706070780079 -0.019806051263036 -0.019906031547932 -0.020006011633767 -0.020105991519543 -0.020205971204258 -0.020305950686914 -0.020405929966510 -0.020505909042047 Columns 208 through 216 -0.020605887912525 -0.020705866576944 -0.020805845034304 -0.020905823283606 -0.021005801323850 -0.021105779154036 -0.021205756773163 -0.021305734180234 -0.021405711374247 Columns 217 through 225 -0.021505688354203 -0.021605665119101 -0.021705641667944 -0.021805617999730 -0.021905594113459 -0.022005570008133 -0.022105545682751 -0.022205521136314 -0.022305496367821 Columns 226 through 234 -0.022405471376274 -0.022505446160671 -0.022605420720015 -0.022705395053304 -0.022805369159539 -0.022905343037720 -0.023005316686849 -0.023105290105923 -0.023205263293945 Columns 235 through 243 -0.023305236249914 -0.023405208972831 -0.023505181461696 -0.023605153715509 -0.023705125733271 -0.023805097513981 -0.023905069056640 -0.024005040360249 -0.024105011423807 Columns 244 through 252 -0.024204982246315 -0.024304952826773 -0.024404923164182 -0.024504893257542 -0.024604863105852 -0.024704832708114 -0.024804802063327 -0.024904771170493 -0.025004740028611 Columns 253 through 261 -0.025104708636681 -0.025204676993704 -0.025304645098681 -0.025404612950611 -0.025504580548495 -0.025604547891333 -0.025704514978126 -0.025804481807874 -0.025904448379577 Columns 262 through 270 -0.026004414692235 -0.026104380744849 -0.026204346536420 -0.026304312065946 -0.026404277332430 -0.026504242334871 -0.026604207072270 -0.026704171543626 -0.026804135747941 Columns 271 through 279 -0.026904099684214 -0.027004063351447 -0.027104026748638 -0.027203989874790 -0.027303952728901 -0.027403915309973 -0.027503877617006 -0.027603839649001 -0.027703801404956 Columns 280 through 288 -0.027803762883874 -0.027903724084754 -0.028003685006597 -0.028103645648403 -0.028203606009172 -0.028303566087906 -0.028403525883604 -0.028503485395267 -0.028603444621894 Columns 289 through 297 -0.028703403562488 -0.028803362216047 -0.028903320581572 -0.029003278658065 -0.029103236444524 -0.029203193939951 -0.029303151143347 -0.029403108053711 -0.029503064670044 Columns 298 through 306 -0.029603020991345 -0.029702977016617 -0.029802932744859 -0.029902888175072 -0.030002843306256 -0.030102798137412 -0.030202752667539 -0.030302706895639 -0.030402660820712 Columns 307 through 315 -0.030502614441758 -0.030602567757779 -0.030702520767773 -0.030802473470742 -0.030902425865687 -0.031002377951607 -0.031102329727503 -0.031202281192377 -0.031302232345227 Columns 316 through 324 -0.031402183185055 -0.031502133710861 -0.031602083921646 -0.031702033816410 -0.031801983394154 -0.031901932653878 -0.032001881594582 -0.032101830215268 -0.032201778514935 Columns 325 through 333 -0.032301726492585 -0.032401674147217 -0.032501621477833 -0.032601568483433 -0.032701515163016 -0.032801461515585 -0.032901407540139 -0.033001353235679 -0.033101298601205 Columns 334 through 342 -0.033201243635718 -0.033301188338220 -0.033401132707708 -0.033501076743186 -0.033601020443653 -0.033700963808110 -0.033800906835557 -0.033900849524995 -0.034000791875425 Columns 343 through 351 -0.034100733885846 -0.034200675555261 -0.034300616882668 -0.034400557867070 -0.034500498507465 -0.034600438802856 -0.034700378752243 -0.034800318354625 -0.034900257609005 Columns 352 through 360 -0.035000196514382 -0.035100135069756 -0.035200073274130 -0.035300011126503 -0.035399948625876 -0.035499885771249 -0.035599822561623 -0.035699758995999 -0.035799695073378 Columns 361 through 369 -0.035899630792759 -0.035999566153145 -0.036099501153535 -0.036199435792929 -0.036299370070330 -0.036399303984736 -0.036499237535150 -0.036599170720571 -0.036699103540000 Columns 370 through 378 -0.036799035992439 -0.036898968076887 -0.036998899792345 -0.037098831137815 -0.037198762112295 -0.037298692714789 -0.037398622944295 -0.037498552799816 -0.037598482280350 Columns 379 through 387 -0.037698411384901 -0.037798340112466 -0.037898268462049 -0.037998196432648 -0.038098124023266 -0.038198051232903 -0.038297978060559 -0.038397904505235 -0.038497830565932 Columns 388 through 396 -0.038597756241651 -0.038697681531393 -0.038797606434157 -0.038897530948946 -0.038997455074759 -0.039097378810597 -0.039197302155462 -0.039297225108354 -0.039397147668274 Columns 397 through 405 -0.039497069834221 -0.039596991605199 -0.039696912980206 -0.039796833958245 -0.039896754538314 -0.039996674719417 -0.040096594500553 -0.040196513880723 -0.040296432858927 Columns 406 through 414 -0.040396351434167 -0.040496269605444 -0.040596187371758 -0.040696104732111 -0.040796021685502 -0.040895938230933 -0.040995854367404 -0.041095770093917 -0.041195685409472 Columns 415 through 423 -0.041295600313071 -0.041395514803713 -0.041495428880401 -0.041595342542133 -0.041695255787913 -0.041795168616740 -0.041895081027616 -0.041994993019540 -0.042094904591515 Columns 424 through 432 -0.042194815742541 -0.042294726471618 -0.042394636777748 -0.042494546659932 -0.042594456117170 -0.042694365148464 -0.042794273752814 -0.042894181929221 -0.04...

Matrix dimensions must agree. Error in Test1 (line 1) assert(all(abs(find_zeros(@sin,0,2*pi) -[0 pi 2*pi])<1e-9))

2   Fail
assert(all(abs(find_zeros(@cos,0,2*pi) -[-pi/2 pi/2 3*pi/2])<1e-9))

ans = Columns 1 through 9 -0.000003673205103 -0.000103673204918 -0.000203673203695 -0.000303673200436 -0.000403673194140 -0.000503673183808 -0.000603673168438 -0.000703673147032 -0.000803673118589 Columns 10 through 18 -0.000903673082110 -0.001003673036593 -0.001103672981040 -0.001203672914451 -0.001303672835824 -0.001403672744161 -0.001503672638461 -0.001603672517724 -0.001703672380951 Columns 19 through 27 -0.001803672227141 -0.001903672055294 -0.002003671864410 -0.002103671653490 -0.002203671421533 -0.002303671167540 -0.002403670890509 -0.002503670589442 -0.002603670263338 Columns 28 through 36 -0.002703669911198 -0.002803669532020 -0.002903669124806 -0.003003668688556 -0.003103668222269 -0.003203667724945 -0.003303667195584 -0.003403666633186 -0.003503666036752 Columns 37 through 45 -0.003603665405282 -0.003703664737774 -0.003803664033230 -0.003903663290650 -0.004003662509033 -0.004103661687379 -0.004203660824688 -0.004303659919961 -0.004403658972198 Columns 46 through 54 -0.004503657980397 -0.004603656943561 -0.004703655860687 -0.004803654730777 -0.004903653552831 -0.005003652325847 -0.005103651048828 -0.005203649720772 -0.005303648340679 Columns 55 through 63 -0.005403646907550 -0.005503645420384 -0.005603643878182 -0.005703642279944 -0.005803640624669 -0.005903638911358 -0.006003637139010 -0.006103635306626 -0.006203633413206 Columns 64 through 72 -0.006303631457749 -0.006403629439256 -0.006503627356727 -0.006603625209161 -0.006703622995559 -0.006803620714921 -0.006903618366247 -0.007003615948536 -0.007103613460790 Columns 73 through 81 -0.007203610902007 -0.007303608271188 -0.007403605567333 -0.007503602789442 -0.007603599936515 -0.007703597007552 -0.007803594001553 -0.007903590917518 -0.008003587754447 Columns 82 through 90 -0.008103584511340 -0.008203581187198 -0.008303577781020 -0.008403574291805 -0.008503570718556 -0.008603567060270 -0.008703563315949 -0.008803559484592 -0.008903555565199 Columns 91 through 99 -0.009003551556771 -0.009103547458307 -0.009203543268808 -0.009303538987274 -0.009403534612704 -0.009503530144099 -0.009603525580458 -0.009703520920782 -0.009803516164071 Columns 100 through 108 -0.009903511309325 -0.010003506355544 -0.010103501301727 -0.010203496146876 -0.010303490889990 -0.010403485530069 -0.010503480066113 -0.010603474497122 -0.010703468822096 Columns 109 through 117 -0.010803463040036 -0.010903457149941 -0.011003451150811 -0.011103445041647 -0.011203438821449 -0.011303432489216 -0.011403426043949 -0.011503419484647 -0.011603412810312 Columns 118 through 126 -0.011703406019942 -0.011803399112538 -0.011903392087100 -0.012003384942628 -0.012103377678123 -0.012203370292584 -0.012303362785011 -0.012403355154404 -0.012503347399764 Columns 127 through 135 -0.012603339520090 -0.012703331514383 -0.012803323381642 -0.012903315120869 -0.013003306731062 -0.013103298211222 -0.013203289560349 -0.013303280777443 -0.013403271861505 Columns 136 through 144 -0.013503262811533 -0.013603253626529 -0.013703244305493 -0.013803234847424 -0.013903225251323 -0.014003215516189 -0.014103205641024 -0.014203195624826 -0.014303185466596 Columns 145 through 153 -0.014403175165335 -0.014503164720042 -0.014603154129717 -0.014703143393360 -0.014803132509972 -0.014903121478553 -0.015003110298103 -0.015103098967621 -0.015203087486108 Columns 154 through 162 -0.015303075852565 -0.015403064065991 -0.015503052125386 -0.015603040029751 -0.015703027778085 -0.015803015369389 -0.015903002802663 -0.016002990076907 -0.016102977191121 Columns 163 through 171 -0.016202964144305 -0.016302950935459 -0.016402937563584 -0.016502924027680 -0.016602910326746 -0.016702896459784 -0.016802882425792 -0.016902868223771 -0.017002853852722 Columns 172 through 180 -0.017102839311644 -0.017202824599538 -0.017302809715404 -0.017402794658241 -0.017502779427051 -0.017602764020833 -0.017702748438587 -0.017802732679314 -0.017902716742013 Columns 181 through 189 -0.018002700625685 -0.018102684329330 -0.018202667851949 -0.018302651192540 -0.018402634350105 -0.018502617323644 -0.018602600112157 -0.018702582714643 -0.018802565130104 Columns 190 through 198 -0.018902547357539 -0.019002529395949 -0.019102511244333 -0.019202492901693 -0.019302474367027 -0.019402455639337 -0.019502436717622 -0.019602417600882 -0.019702398288119 Columns 199 through 207 -0.019802378778331 -0.019902359070520 -0.020002339163685 -0.020102319056827 -0.020202298748945 -0.020302278239041 -0.020402257526114 -0.020502236609164 -0.020602215487192 Columns 208 through 216 -0.020702194159197 -0.020802172624181 -0.020902150881143 -0.021002128929084 -0.021102106767003 -0.021202084393901 -0.021302061808778 -0.021402039010635 -0.021502015998471 Columns 217 through 225 -0.021601992771287 -0.021701969328084 -0.021801945667860 -0.021901921789617 -0.022001897692355 -0.022101873375074 -0.022201848836774 -0.022301824076456 -0.022401799093119 Columns 226 through 234 -0.022501773885765 -0.022601748453392 -0.022701722795002 -0.022801696909595 -0.022901670796171 -0.023001644453731 -0.023101617881273 -0.023201591077800 -0.023301564042311 Columns 235 through 243 -0.023401536773806 -0.023501509271286 -0.023601481533750 -0.023701453560200 -0.023801425349635 -0.023901396901056 -0.024001368213463 -0.024101339285857 -0.024201310117237 Columns 244 through 252 -0.024301280706604 -0.024401251052958 -0.024501221155300 -0.024601191012629 -0.024701160623946 -0.024801129988252 -0.024901099104547 -0.025001067971830 -0.025101036589103 Columns 253 through 261 -0.025201004955366 -0.025300973069618 -0.025400940930861 -0.025500908538094 -0.025600875890318 -0.025700842986534 -0.025800809825741 -0.025900776406940 -0.026000742729131 Columns 262 through 270 -0.026100708791315 -0.026200674592492 -0.026300640131662 -0.026400605407825 -0.026500570419983 -0.026600535167134 -0.026700499648281 -0.026800463862422 -0.026900427808559 Columns 271 through 279 -0.027000391485692 -0.027100354892820 -0.027200318028945 -0.027300280893067 -0.027400243484186 -0.027500205801303 -0.027600167843417 -0.027700129609530 -0.027800091098642 Columns 280 through 288 -0.027900052309752 -0.028000013241863 -0.028099973893973 -0.028199934265083 -0.028299894354194 -0.028399854160306 -0.028499813682419 -0.028599772919535 -0.028699731870652 Columns 289 through 297 -0.028799690534773 -0.028899648910896 -0.028999606998023 -0.029099564795154 -0.029199522301289 -0.029299479515429 -0.029399436436574 -0.029499393063725 -0.029599349395882 Columns 298 through 306 -0.029699305432045 -0.029799261171215 -0.029899216612393 -0.029999171754578 -0.030099126596772 -0.030199081137975 -0.030299035377186 -0.030398989313408 -0.030498942945639 Columns 307 through 315 -0.030598896272882 -0.030698849294135 -0.030798802008399 -0.030898754414676 -0.030998706511965 -0.031098658299267 -0.031198609775582 -0.031298560939911 -0.031398511791255 Columns 316 through 324 -0.031498462328614 -0.031598412550988 -0.031698362457377 -0.031798312046784 -0.031898261318207 -0.031998210270647 -0.032098158903105 -0.032198107214582 -0.032298055204078 Columns 325 through 333 -0.032398002870593 -0.032497950213128 -0.032597897230684 -0.032697843922261 -0.032797790286859 -0.032897736323479 -0.032997682031122 -0.033097627408788 -0.033197572455478 Columns 334 through 342 -0.033297517170192 -0.033397461551931 -0.033497405599695 -0.033597349312486 -0.033697292689302 -0.033797235729146 -0.033897178431018 -0.033997120793917 -0.034097062816846 Columns 343 through 351 -0.034197004498804 -0.034296945838792 -0.034396886835810 -0.034496827488860 -0.034596767796941 -0.034696707759055 -0.034796647374201 -0.034896586641381 -0.034996525559595 Columns 352 through 360 -0.035096464127844 -0.035196402345128 -0.035296340210448 -0.035396277722805 -0.035496214881199 -0.035596151684631 -0.035696088132102 -0.035796024222611 -0.035895959955160 Columns 361 through 369 -0.035995895328750 -0.036095830342381 -0.036195764995053 -0.036295699285768 -0.036395633213526 -0.036495566777327 -0.036595499976173 -0.036695432809064 -0.036795365275000 Columns 370 through 378 -0.036895297372983 -0.036995229102013 -0.037095160461090 -0.037195091449216 -0.037295022065391 -0.037394952308616 -0.037494882177891 -0.037594811672218 -0.037694740790596 Columns 379 through 387 -0.037794669532027 -0.037894597895511 -0.037994525880049 -0.038094453484642 -0.038194380708291 -0.038294307549995 -0.038394234008757 -0.038494160083576 -0.038594085773454 Columns 388 through 396 -0.038694011077391 -0.038793935994387 -0.038893860523444 -0.038993784663563 -0.039093708413744 -0.039193631772988 -0.039293554740295 -0.039393477314667 -0.039493399495104 Columns 397 through 405 -0.039593321280607 -0.039693242670177 -0.039793163662815 -0.039893084257520 -0.039993004453295 -0.040092924249140 -0.040192843644056 -0.040292762637043 -0.040392681227103 Columns 406 through 414 -0.040492599413236 -0.040592517194443 -0.040692434569725 -0.040792351538082 -0.040892268098516 -0.040992184250027 -0.041092099991616 -0.041192015322284 -0.041291930241033 Columns 415 through 423 -0.041391844746861 -0.041491758838772 -0.041591672515765 -0.041691585776841 -0.041791498621001 -0.041891411047246 -0.041991323054577 -0.042091234641995 -0.042191145808501 Columns 424 through 432 -0.042291056553095 -0.042390966874778 -0.042490876772552 -0.042590786245418 -0.042690695292375 -0.042790603912425 -0.042890512104569 -0.042990419867808 -0.04...

Matrix dimensions must agree. Error in Test2 (line 1) assert(all(abs(find_zeros(@cos,0,2*pi) -[-pi/2 pi/2 3*pi/2])<1e-9))

3   Fail
assert(all(abs(find_zeros(@tan,0,pi/4) -0)<1e-9))

ans = 0

Assertion failed.