Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================= RESTART: C:\Users\Admin\Desktop\8\NR\NR.py ================= >>> f1 = lambda x: x**3 - 4*x**2 + 3*x >>> f1(2) -2 >>> f1(1) 0 >>> f1(3) 0 >>> f1(0) 0 >>> f11 = lambda x: 3*x**2 - 8*x + 3 >>> f11(3) 6 >>> NR(f1, f11, x0=5) 5 40 3.947368421052632 11.022014870972447 3.340636586892667 2.663511124945501 3.0675810243556922 0.42863077610556743 3.0035059786544434 0.021097374453381335 3.0000101979512923 6.118822774503485e-05 3.000000000086664 5.199822794565989e-10 convergence in 6 iterations 3.000000000086664 >>> f1(5) 40 >>> NR(f1, f11, x0=4) 4 12 3.3684210526315788 2.9392039655926503 3.0771631246659057 0.4932089276860694 3.00452016332014 0.02722323165845708 3.000016929634699 0.00010157924126374951 3.0000000002388383 1.4330296949083277e-09 convergence in 5 iterations 3.0000000002388383 >>> NR(f1, f11, x0=1.5) 1.5 -1.125 1.0 0.0 convergence in 1 iterations 1.0 >>> NR(f1, f11, x0=1) 1 0 convergence in 0 iterations 1 >>> NR(f1, f11, x0=-1) -1 -8 -0.4285714285714286 -2.099125364431487 -0.12781954887218044 -0.4508982898764238 -0.01707644468701397 -0.052400733489660165 -0.0003749431439753065 -0.0011253918140811683 -1.8729099961407088e-07 -5.618731391538933e-07 -4.677053907742991e-14 -1.403116172322985e-13 convergence in 6 iterations -4.677053907742991e-14 >>> NR(f1, f11, x0=-100) -100 -1040300 -66.22731552121547 -308219.713332865 -43.714721300088456 -91312.87237072227 -28.71009612498539 -27048.068775318116 -18.712619697719994 -8009.237285500867 -12.055936361790135 -2369.827538191346 -7.630358323771604 -700.0380790044833 -4.69776997833485 -206.04476758479447 -2.7683183340381365 -60.174547328052434 -1.5182577782389557 -17.274946207826037 -0.7352177131683565 -4.765251804345393 -0.2815301209486466 -1.183941053547825 -0.06587674325083545 -0.2152750992448425 -0.005065138335694455 -0.015298167461818852 -3.383623929994681e-05 -0.00010151329750293909 -1.526409549518009e-09 -4.579228657873731e-09 convergence in 15 iterations -1.526409549518009e-09 >>> NR(f1, f11, x0=-100000) -100000 -1000040000300000 -66666.22222740731 -296308148219753.06 -44443.70371493805 -87795006868404.23 -29628.69137718064 -26013335360734.4 -19752.016491175465 -7707654916578.032 -13167.566575921548 -2283749601498.0415 -8777.93331220964 -676666546316.0984 -5851.511156087157 -200493789983.85406 -3900.563081532355 -59405566391.21271 -2599.931076116429 -17601648626.890217 -1732.8431389299687 -5215302847.447095 -1154.7846137600336 -1545274618.2198637 -769.4124130441114 -457858946.5082912 -512.4978365859797 -135661777.05308574 -341.2217881363312 -40195993.47125907 -227.0382592313489 -11909864.976075971 -150.91666084613706 -3528809.601618618 -100.17005795293787 -1045547.091633408 -66.3406789955014 -309774.3777597209 -43.7902842677245 -91773.49409216132 -28.760452547121247 -27184.536230391623 -18.746162607763686 -8049.663391523245 -12.078256899545803 -2381.799858608273 -7.645178007963377 -703.581594543054 -4.707561809531958 -207.0921659925094 -2.7747205698135593 -60.48323833539264 -1.5223496356513133 -17.365361542014792 -0.7377030099488675 -4.791394159104298 -0.2828630233497016 -1.1912673219212826 -0.06638462948941617 -0.21707411628519563 -0.00513861435120129 -0.0155216001703541 -3.4819550498594795e-05 -0.00010446350114238735 -1.6164128500593348e-09 -4.849238560629167e-09 convergence in 32 iterations -1.6164128500593348e-09 >>> NR(f1, f11) -95.8090804606884 -916472.8941322183 -63.43358785010389 -271530.92478080734 -41.85256264942704 -80442.60298436883 -27.46914321418602 -23827.569934784457 -17.886039244499862 -7055.229683700944 -11.505947740035863 -2087.301163334085 -7.265259219871901 -616.4211249263717 -4.456630456939815 -181.3317225573661 -2.610784041398605 -52.89273408646339 -1.4177557265207974 -15.143125766070476 -0.674430480383648 -4.1494864021366915 -0.24927876276988287 -1.011886052363517 -0.053958467037294955 -0.17367856672096277 -0.0034764151305679628 -0.010477629254427568 -1.5993498869676208e-05 -4.798151978114401e-05 -3.410441900708486e-10 -1.0231325706777904e-09 convergence in 15 iterations -3.410441900708486e-10 >>> NR(f1, f11) 6.228189231136412 105.11678800196063 4.716707198189266 30.09494084790267 3.7764848366240775 8.141717521565784 3.253696303423879 1.8603152467855377 3.040602956736085 0.2519276789334306 3.001306646192646 0.007848416008110704 3.0000014204193284 8.52252605909598e-06 3.0000000000016813 1.0089706847793423e-11 convergence in 7 iterations 3.0000000000016813 >>> NR(f1, f11) 3.442251714967881 3.7179416869282775 3.1045418249541425 0.6830384524389181 3.0080430049373095 0.04858199956738041 3.0000533646281324 0.00032020200785964903 3.0000000023729934 1.4237961920571252e-08 2.9999999999999996 -5.329070518200751e-15 convergence in 5 iterations 2.9999999999999996 >>> NR(f1, f11, epsilon = 10**(-15)) -27.259071539683674 -23309.048548186056 -17.746119705874367 -6901.629988784561 -11.412857279765156 -2041.81426894251 -7.203475933300224 -602.959528048916 -4.415842590360824 -177.35364556414763 -2.584163853935097 -51.720897955576426 -1.400809354363634 -14.800257207598726 -0.6642317217920396 -4.050571832921918 -0.24393740325797109 -0.9843496431959695 -0.05205696454598688 -0.16715167447172474 -0.0032476489314323675 -0.009785169942303834 -1.3964713309732885e-05 -4.189491998479325e-05 -2.600097566840819e-10 -7.80029270322666e-10 -9.014009439779966e-20 -2.70420283193399e-19 convergence in 13 iterations -9.014009439779966e-20 >>> NR(f11, lambda x: 6*x-8) -78.94535754810144 19331.671295577544 -38.8108563429417 4832.334560960907 -18.748448806802926 1207.5005884383536 -8.726922994567747 301.29293881588785 -3.735450792872398 74.74438422089227 -1.277781051968721 18.12042166606064 -0.1211598427728584 4.013317864685098 0.3387160244838847 0.6344574398554252 0.44503119284234804 0.03390874506926522 0.45139328210672885 0.00012142853942398446 0.4514162293465961 1.5797274599549382e-09 convergence in 10 iterations 0.4514162293465961 >>> NR(f1, f11, x0=0.4514162293465961) zero derivative, x0= 0.4514162293465961 i= 0 xi= 0.4514162293465961 >>> f1 = lambda x: x**3 - 4*x**2 + 3*x >>> f111 = diff_param(f1) >>> f11 = lambda x: 3*x**2 - 8*x + 3 >>> f11(5) 38 >>> f111(5) 38.0110010000152 >>> NR(f1, f11, x0=10) 10 630 7.174887892376681 184.96476913841624 5.325941795893695 53.58903426358909 4.147887247022127 14.988057184494256 3.448550201901587 3.787534711731766 3.106995269084695 0.7004364330551365 3.008401915343808 0.050765046079604303 3.0000582073774584 0.0003492612054412092 3.0000000028232074 1.693924644996514e-08 2.9999999999999996 -5.329070518200751e-15 convergence in 9 iterations 2.9999999999999996 >>> NR(f1, f111, x0=10) 10 630 7.175217251911281 184.99771949071396 5.326479016163002 53.61347556642001 4.148530681260346 15.001850639468746 3.449180272840524 3.7945241469244166 3.1074371608417377 0.7035768022922522 3.008541343571467 0.05161345730870792 3.0000671443168527 0.00040288844321523243 3.000000059667697 3.580061971319992e-07 3.000000000049695 2.9816682456385024e-10 convergence in 9 iterations 3.000000000049695 >>> NR(f1, f11, x0=100) 100 960300 67.11639215149128 284516.0864493552 45.19664661407067 84289.49869925735 30.587496588509335 24966.889966032766 20.85413834428969 7392.344361123709 14.374469307909242 2186.7519452719994 10.068825372748655 645.4715443743399 7.220232637985668 189.53709083760052 5.3553234717718965 54.93595567590363 4.166127490268248 15.381793902741265 3.4586204422482596 3.89984908423099 3.1109536272884264 0.7286412184143067 3.008995404271178 0.054377740000884245 3.0000666714510746 0.00040005093215533805 3.0000000037039225 2.222353678860145e-08 2.9999999999999996 -5.329070518200751e-15 convergence in 15 iterations 2.9999999999999996 >>> NR(f1, f111, x0=100) 100 960300 67.1167254558865 284520.41272871493 45.19720204556927 84292.70337821353 30.588199913474767 24968.694097673724 20.85493979852538 7393.258739529663 14.375335064249981 2187.1916752296206 10.069731331916852 645.6768500080994 7.221159006449133 189.6312559863578 5.356247905758664 54.978671030165316 4.167012340410871 15.40103793816413 3.459386451112332 3.908445302427337 3.1114541946057472 0.7322198432949563 3.009148036937578 0.055307420092447046 3.000076428207293 0.00045859845055851167 3.0000000685078754 4.1104727799279317e-07 3.0000000000570575 3.4234659551657387e-10 convergence in 15 iterations 3.0000000000570575 >>> f111 = diff_param(f1, h=000001) SyntaxError: invalid token >>> f1111 = diff_param(f1, h=0.00001) >>> f1111(5) 38.00010999839287 >>> NR(f1, f1111, x0=100) 100 960300 67.11639549551657 284516.1298544684 45.196652177455476 84289.53079797457 30.587503635970428 24966.908043372947 20.85414636767711 7392.353514626278 14.374477972011588 2186.756345602261 10.068834436686478 645.473598202536 7.2202419045746815 189.53803263422185 5.355332718243837 54.93638282584977 4.16613634039854 15.381986312628207 3.4586281029889587 3.8999350166852924 3.1109586311716977 0.7286769786414897 3.0089969265712235 0.054387011119391815 3.000066767603176 0.00040062790891681743 3.0000000042709356 2.562561540742081e-08 3.0000000000000355 2.1316282072803006e-13 convergence in 15 iterations 3.0000000000000355 >>> NR(sin_by_million, sin_by_million_deriv, x0=5) 5 -0.9765424686570843 4.9999954647951625 -0.03982982671627804 4.99999550465662 2.109114325154512e-05 4.999995504635528 4.122283666762455e-10 convergence in 3 iterations 4.999995504635528 >>> NR(sin_by_million, diff_param(sin_by_million), x0=5) 5 -0.9765424686570843 5.003917017291797 0.7208476850575305 5.001119203982546 -0.8364772493081046 5.0021403052173365 0.7877825243769632 5.003062692178523 0.8377300463606889 4.993199847085811 0.38262884947637 4.993610656575995 -0.9051733726778727 4.994821458365334 -0.15618816592664206 4.994612756766101 0.931913591866192 4.995929543622435 -0.6743760415609281 4.996674151806115 0.6360701290854601 4.997368245613877 -0.7755357225460957 4.9982685628152055 0.8040875922450342 4.992512882024309 0.606053484865707 4.990968789078038 0.7955190554690399 4.9919056133457875 0.2861503327233335 4.992217484052843 0.5335797727339134 4.991072039033316 -0.9740456894777609 4.992659911438145 -0.025645936547006542 4.992628458865095 0.010997543557186632 4.992641682751949 -0.602411157477693 4.991121885101731 -0.9817989858806241 4.994723332636274 -0.5476278363382436 4.995311217835878 0.1713040649761819 4.995503775875139 0.680712074805523 4.993292506122869 0.9168869904936133 5.00616967525505 -0.8081800054857476 5.000106912929725 -0.9930172010500578 5.003053390500079 -0.8984438901533383 5.032897389781341 0.014714702134653623 5.03291504962478 0.9336343616288479 5.034239750437033 0.774470321836184 5.0300345133048125 -0.783503627170586 5.030949084118539 0.5080616117936206 5.031492728982468 -0.3742593515842665 5.0318949123140175 -0.3184804757646629 5.032239887892363 -0.7978615834987902 5.033181164714741 -0.8504706305334684 5.019632927900758 0.6228750386470001 5.020310357228375 0.9673341555957037 5.024836790368521 -0.6538192408147583 5.022911153730609 0.7657970232536732 5.019016402705778 0.9921540840980064 5.020862048362695 0.08521853973989105 5.020753707522779 -0.9916357975652605 5.022587747227897 -0.8673338500762209 4.9954807587443275 0.2737097735029886 4.995779867629079 0.3712312433443165 4.995166599352619 0.2738312951146224 4.995465832998817 0.48378097927962593 4.994520880509187 -0.9214781303221409 5.005748411332706 -0.6056229306968859 5.004207219726695 0.9170653955451066 5.0054616962323 -0.17865616742984208 5.005662037313776 -0.7836182517777995 5.006576815999568 0.31954116904462204 5.0069228771769 -0.16004891510311575 5.00670838602041 0.645834527533009 5.0074150389446075 -0.7879907372372479 5.008337809237813 -0.9811078209510321 5.011979854412808 0.7353589228004829 5.012813437429311 0.23261651576622738 5.012482263182836 0.8782789029191305 5.013608659489714 -0.5922804422710986 5.012153599810481 0.1312259872826521 5.011981455419086 -0.699580403186685 5.00952419185268 -0.23449477001396618 5.009189774596132 0.9214266893949534 5.010461547312717 -0.9850300225422783 5.0138755092461045 0.43340442171737203 5.0130953266037945 -0.5805444516875296 5.013721367087343 -0.24172995224685087 5.013374338717636 0.935272966797552 5.0147067309146465 0.7526763279249663 5.015568116981659 0.2594355678718969 5.015852554005257 -0.9902787925967691 5.018963210254924 -0.9427635533761648 5.0203328970569405 -0.9575610573324355 5.021789528074605 -0.7140044350912347 5.019110026606001 0.8782862282380337 4.9392934774547195 -0.17305255581557968 4.9394878889320095 -0.515160911539841 4.940039359634964 -0.91308766399948 4.9546686280714365 0.02224006813864488 4.954641404523174 -0.8786500680571989 4.869264714239293 -0.30000471491679787 4.868808435553889 -0.4286997150253045 4.869267109698217 -0.42723836856157 4.869724253250044 -0.9212106949093908 4.881036897607216 0.8077895409242027 4.875004831774772 0.6686970024727052 4.872929280954845 -0.9793485094254142 4.874573141295245 0.5310430194882607 4.87514229016016 -0.039226335573540466 4.875188799406593 0.6082704682284867 4.875848163440396 0.8543522865389104 4.876911310302181 -0.26117731252913 4.8765294065724785 -0.9979514608142147 4.878567603783331 0.8066100698264109 4.872626414229649 -0.47990691863169127 no convergence, x0= 5 i= 99 xi= 4.871695315771791 >>> NR(sin_by_million, diff_param(sin_by_million, h=10**(-6)), x0=5) 5 -0.9765424686570843 5.00000364756242 0.9585449483296722 5.000005056336291 -0.12658230151194205 5.000004893322469 0.03608318566306196 5.000004935401477 -0.005987952117038359 5.000004928261941 0.0011515483964375912 5.000004929629576 -0.0002160864410055609 5.000004929372749 4.073972709037373e-05 5.000004929421163 -7.674145617092516e-06 5.000004929412043 1.446296356041036e-06 5.000004929413762 -2.729251166986298e-07 5.000004929413437 5.117513926755329e-08 5.000004929413498 -8.429505507837314e-09 convergence in 12 iterations 5.000004929413498 >>> f2 = lambda x: x**2+1 >>> NR(f2, diff_param(f2)) -89.3866686465658 7990.976531730948 -44.687490615417026 1997.9718175029848 -22.3323063661395 499.7319076311148 -11.143513586971517 125.17789506301881 -5.526635617378501 31.543701247276644 -2.6725886457416483 8.142730069347177 -1.1489247354283032 2.3200280476789965 -0.13883327009003232 1.0192746768838918 3.545293752354989 13.569107790487319 1.6318846910584344 3.6630476449108818 0.5098919203052665 1.2599897703925924 -0.724443617019761 1.524818554240674 0.3286898856403364 1.1080370409222575 -1.3542856389066633 2.834089591748829 -0.3075580365816697 1.0945919458659716 1.4748280524648778 3.175117784337344 0.3987562665889828 1.1590065601439838 -1.0527006761483964 2.108178713563291 -0.05090569475723883 1.002591389758717 9.894313735185865 98.89744429028765 4.8968753327493255 24.979388024488816 2.3465921374386784 6.506494659489025 0.9605164577276031 1.9225918655655823 -0.039774354206915996 1.0015819992525772 12.711320087418711 162.57765836481443 6.316576563407812 40.89913948139285 3.0793877252752875 10.482628762576109 1.377600241830625 2.897782426291797 0.32623172075583806 1.1064271356273152 -1.3669420137500587 2.8685304689550657 -0.3173071078811962 1.100683800711929 1.4198442585659716 3.0159577185827535 0.3581447091806629 1.1282676327141017 -1.214815387305876 2.4757764252351255 -0.19540294671744962 1.0381823115858624 2.46792854485577 7.090671302513918 1.0316562012038386 2.064314517482335 0.03165517661328221 1.001002050206418 -15.533522123543424 242.290309562613 -7.734321567602954 60.81973011108822 -3.8022596768912442 15.457178650513109 -1.769361760635276 4.130641039998364 -0.6017631579851954 1.3621188983083152 0.53095126183127 1.2819092424402179 -0.6750946491549663 1.455752785317667 0.4038886982086627 1.1631260805406882 -1.0342401190566997 2.0696526238664164 -0.03318937829832436 1.0011015348318293 15.279147333865932 234.45234324998242 7.607100390396851 58.86797634957592 3.738076432207869 14.97321541302791 1.7355474369420425 4.012124905876092 0.5800130833004502 1.336415176799695 -0.5710507042732005 1.3260989068509184 0.5910711693121222 1.3493651271919995 -0.5494214689288024 1.301863950519883 0.6364166010052945 1.4050260900351321 -0.4665740321617793 1.217691327487701 0.839754194106942 1.7051871065201996 -0.17493107523143636 1.0306008810816265 2.7792468994033444 8.724213327843103 1.210000913425892 2.464102210491493 0.19219820747090388 1.0369401509550287 -2.4983824797197394 7.241915014970554 -1.0487716445887356 2.099921962493361 -0.04716009984588165 1.0022240750174736 10.692466243943976 115.32883437788139 5.299723400335276 29.087068120061303 2.5557760302853234 7.531991116981007 1.08254093600203 2.171894878120151 0.07985728577112017 1.0063771860907305 -6.182034068785486 39.21754522762443 -3.0098809437507086 10.059383295553657 -1.3385433026251004 2.791698173002511 -0.29534157382996784 1.0872266452323625 1.54840561404004 3.397559945590713 0.4516441604066004 1.203982447629383 -0.8797701904352013 1.7739955879783904 0.1290184659278213 1.0166457645503684 -3.7956951155207266 15.407301409987902 -1.765851992702094 4.118233260129956 -0.59944629084913 1.35933585561278 0.5353264562075639 1.2865744147157487 -0.6652249534984673 1.442524238757038 0.4198285194944018 1.1762559857808612 -0.9793817781979115 1.959188667466103 0.021346149884003296 1.0004556581148702 -22.876410741437812 524.3301684109713 -11.416098311975341 131.32730066868623 -5.663999425884573 33.080889496420774 -2.743465052276232 8.526600493061029 -1.1891979853323165 2.41419184831844 -0.17372059826337694 1.0301788462609855 2.799883166501006 8.839345746055702 1.2216445433372733 2.492415390265735 0.2019552586884803 1.040785926511931 -2.3684544536953167 6.609576499229181 -0.9728244640823571 1.9463874379171253 0.02806953263203238 1.0007878986621808 -17.48688094895533 306.79100532293694 no convergence, x0= -89.3866686465658 i= 99 xi= -8.714596786267563 >>> f3 = lambda x: x**2-2 >>> NR(f3, diff_param(f3)) -3.0971462439375586 7.592314856336527 -1.8712530907884009 1.501588129785143 -1.469920564016396 0.16066646451827937 -1.4152505571944056 0.002934139639075628 -1.4142135759314702 3.834887651876784e-08 -1.4142135623682996 -1.3563372647240612e-11 convergence in 5 iterations -1.4142135623682996 >>> NR(f3, diff_param(f3)) 59.04930404283127 3484.820307942729 29.5418368764053 870.72012603214 14.80501815969132 217.18856270878976 7.470301455884514 53.805403841790294 3.869255158541797 12.971135481902307 2.1932918287593264 2.81052904610243 1.5527276217871089 0.41096306746065103 1.420434369434352 0.017633797870364898 1.4142293686089493 4.4707036067404005e-05 1.4142135680477044 1.605021893169578e-08 1.4142135623751007 5.6727955666247e-12 convergence in 10 iterations 1.4142135623751007 >>> NR(f3, diff_param(f3)) -7.136933199802911 48.93581549844902 -3.7083426050088186 11.751804876123591 -2.1236198796900663 2.509761393414852 -1.532564843791314 0.3487550004250948 -1.4187462277456477 0.01284085874250529 -1.414219207510622 1.5966891971697095e-05 -1.4142135603878103 -5.615233167333145e-09 convergence in 6 iterations -1.4142135603878103 >>>