2023.03.06 MATH 3600 Newton's Method

199 days ago by calkin

Using Newton's method to approximate $\sqrt{2}$: 

\[ x_{n+1} = \frac{x_n}{2} + \frac{1}{x_n} \]

def g(x): return(x/2+1/x) x=2. for i in srange(20): x=g(x) print(x-sqrt(2.)) 
       
0.0857864376269049
0.00245310429357137
2.12390141451912e-6
1.59472435257157e-12
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
0.0857864376269049
0.00245310429357137
2.12390141451912e-6
1.59472435257157e-12
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16
-2.22044604925031e-16

Let us increase the precision.

R = RealField(1000); R 
       
Real Field with 1000 bits of precision
Real Field with 1000 bits of precision
RealNumber = R 
       
sqrt(2.) 
       
1.4142135623730950488016887242
1.4142135623730950488016887242
def g(x): return(x/2+1/x) x=2. for i in srange(20): x=g(x) print(x-sqrt(2.)) 
       
0.085786437626904951198311275791
0.0024531042935716178649779424585
2.1239014147551198799032413092e-6
1.5948618246068546808560951380e-12
8.9929354334290124805131644714e-25
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
0.085786437626904951198311275791
0.0024531042935716178649779424585
2.1239014147551198799032413092e-6
1.5948618246068546808560951380e-12
8.9929354334290124805131644714e-25
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
1.5777218104420236108234571306e-30
sqrt(2) 
       
sqrt(2)
sqrt(2)
def g(x): return(2*x/3+2/(3*x^2)) x=2. for i in srange(20): x=g(x) print(x-(2.)^(1/3)) 
       
0.2400789501051268352327893927217716494297485352984920199180248878447003\
234860405162706034375637449058456897439643843347406009759593862627715408\
896957306447530393573833749990225254734345196931328145944813107541274832\
358006262903049016172168386008448706863046338160525365514234296968809041\
04015258894019
0.0363752464014231315290856890180679457260448315947883162143211841409966\
197823368125668997338600412021419860402606806310368972722556825590678371\
859920269410493356536796712953188217697308159894291108907776070504237795\
320969225866011979135131348971411669826009301123488328477197259931772004\
003115551903151
0.0010111748468753865051501888920916292735379028973834283332428268721631\
604726870267266377031218199877302954380938879880537780986603184875132894\
409680914409233593372271643666214168818497376321602774314679572645835175\
013587013721895073113463422541580478090055660407942851026957904930512240\
8385904826161769
8.1067105308555988812028773327972363643132461880866942001984713405572088\
773482338849016072472203066097592631629998615470640592860665981987719894\
422421192843510933141986143260283757379566100697873640275030385367426501\
259055220093086055581096273043001191583649762182389840530223116362629549\
0989509601888e-7
5.2160966162166855757859645546163178538305061047628827021654716323361575\
918714806971804912432846727532531077625930372987998923697195215444685241\
727536331064285574737262587002853503215138304328545719469490353754397800\
306232797843740914009767109935411783249870387444981370424827115008384692\
8075236113477e-13
2.1594737155921257867756844852428147591121284375133130469944993003585955\
823617779724586025849637437942540707986871753222630793599212990272798834\
644032399112173371764035701446157662576307372068560871487486262726062239\
911977701262483836016200822518105670355425621582320036543534248846445381\
1106739555418e-25
3.7012848771138205332851150649007809483177983587083478967769964046849592\
519917593422279553385969298868103517699520889509914456766860636221729099\
992690692074865765243255383041510265316212761179146621004697004271040859\
739564475205953839474362966884217885337472768849446138339770400723876021\
5687457955606e-50
1.0873308087593699647968670217995645141243530397068239716551799307842389\
835082165282612715381557067241383952097088541674685085313439861501901364\
456373494955668981565503702425163888157594140900172238823780109481921158\
571681410165109460015135131129266397224870953913972381601023211461258866\
4451217820011e-99
9.3838283579431806233214980586342941737452386520075530929152169848420354\
620843565925077401547549999537065135143583382621420179355614981534996217\
753432348129148452874203400226253949563988007643323965542653721938589117\
999183480735351520931956118033692923357927893418176667443960098183158032\
7919922249338e-199
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
0.240078950105126835232789392721771649429748535298492019918024887844700323486040516270603437563744905845689743964384334740600975959386262771540889695730644753039357383374999022525473434519693132814594481310754127483235800626290304901617216838600844870686304633816052536551423429696880904104015258894019
0.0363752464014231315290856890180679457260448315947883162143211841409966197823368125668997338600412021419860402606806310368972722556825590678371859920269410493356536796712953188217697308159894291108907776070504237795320969225866011979135131348971411669826009301123488328477197259931772004003115551903151
0.00101117484687538650515018889209162927353790289738342833324282687216316047268702672663770312181998773029543809388798805377809866031848751328944096809144092335933722716436662141688184973763216027743146795726458351750135870137218950731134634225415804780900556604079428510269579049305122408385904826161769
8.10671053085559888120287733279723636431324618808669420019847134055720887734823388490160724722030660975926316299986154706405928606659819877198944224211928435109331419861432602837573795661006978736402750303853674265012590552200930860555810962730430011915836497621823898405302231163626295490989509601888e-7
5.21609661621668557578596455461631785383050610476288270216547163233615759187148069718049124328467275325310776259303729879989236971952154446852417275363310642855747372625870028535032151383043285457194694903537543978003062327978437409140097671099354117832498703874449813704248271150083846928075236113477e-13
2.15947371559212578677568448524281475911212843751331304699449930035859558236177797245860258496374379425407079868717532226307935992129902727988346440323991121733717640357014461576625763073720685608714874862627260622399119777012624838360162008225181056703554256215823200365435342488464453811106739555418e-25
3.70128487711382053328511506490078094831779835870834789677699640468495925199175934222795533859692988681035176995208895099144567668606362217290999926906920748657652432553830415102653162127611791466210046970042710408597395644752059538394743629668842178853374727688494461383397704007238760215687457955606e-50
1.08733080875936996479686702179956451412435303970682397165517993078423898350821652826127153815570672413839520970885416746850853134398615019013644563734949556689815655037024251638881575941409001722388237801094819211585716814101651094600151351311292663972248709539139723816010232114612588664451217820011e-99
9.38382835794318062332149805863429417374523865200755309291521698484203546208435659250774015475499995370651351435833826214201793556149815349962177534323481291484528742034002262539495639880076433239655426537219385891179991834807353515209319561180336929233579278934181766674439600981831580327919922249338e-199
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301

It looks like we are still doubling the precision at each iteration.

Let's try approximating $\pi$ using $f(x) = \tan(x)$

def g(x): return(x-tan(x)) x=2. for i in srange(20): x=g(x) print(x-pi.n(1000)) 
       
1.0434472096717257531806627190341796592348483468525573435880112776589573\
409229851836917087167626114796127504309365251898929750192362550111894171\
468875292884624175751508017217194514114286249411801747915956194526983947\
785289371572435876163344061904381649877431273611352095046271423826044908\
1024132021840
-0.673698979075127787660810116618670113880485938334460796170168128393222\
177507277330419437796659448963583319283608999038579105312166542699764241\
968796164725445738522925122078093724161382274430225304552172984642804693\
086921937747367119461886644131985743950647024318852155266157310234850616\
318283428152352
0.1245936239793133051998969386451741675766712534473935304235600956633665\
067815749223282055944032574347773584984254366127584768260894912893569163\
545775610213938594193462162277654841523078721586903075385104713721726458\
742750571678974019049889441003001583051201189519480530114947360204745832\
46309756371275
-0.000648741272157907683636946345459564226269434632288131952758130818709\
498529905474126410696706310060881779065377263611250624004925678203223476\
854836126563566359552315997823741564467762394155374445626567976462302614\
803960609288555634096738051381846769531728696945751024828677944979044991\
368308900499836127
9.1010898667195049654750556875177836059405932355912200192699889277532045\
935403078052751238886672701361183971188086389285558201201469903784942527\
069417153584181549871959648579708137231307856481703826115132239065986238\
702434381758399964159931809500664369166830291573484677709437640721976398\
6615786471443e-11
-2.512805960058732007163813918169257569254311199850855285204315063418577\
950506651634673058008703498252024435059049651471336033866473179518255037\
839058549719349841245010091921543454100764957900453518216931936797484492\
319465381192792879902443289052698969500142374998898051008746003603003720\
80705680440193e-31
5.2887812652605904221196157219716413415936152427607776522179340379884401\
208479370845895205110648972558390082402510760721540537470390916990717517\
879557687667971696218471933188008968864430153138901793799068482969313767\
431005955382685501421772290133367251217197807792319932310142061988950931\
1410266445282e-93
-4.931119899522181144110377085479585350490649704006754374266257034112717\
591216085091776542603338103211148978915166505139508410189017904526330228\
500976759560679276055642398725554256919135113715773719130584574794681223\
583548464151772605538645058582975433368405404009743233365448685669611086\
87414214190763e-278
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
1.04344720967172575318066271903417965923484834685255734358801127765895734092298518369170871676261147961275043093652518989297501923625501118941714688752928846241757515080172171945141142862494118017479159561945269839477852893715724358761633440619043816498774312736113520950462714238260449081024132021840
-0.673698979075127787660810116618670113880485938334460796170168128393222177507277330419437796659448963583319283608999038579105312166542699764241968796164725445738522925122078093724161382274430225304552172984642804693086921937747367119461886644131985743950647024318852155266157310234850616318283428152352
0.124593623979313305199896938645174167576671253447393530423560095663366506781574922328205594403257434777358498425436612758476826089491289356916354577561021393859419346216227765484152307872158690307538510471372172645874275057167897401904988944100300158305120118951948053011494736020474583246309756371275
-0.000648741272157907683636946345459564226269434632288131952758130818709498529905474126410696706310060881779065377263611250624004925678203223476854836126563566359552315997823741564467762394155374445626567976462302614803960609288555634096738051381846769531728696945751024828677944979044991368308900499836127
9.10108986671950496547505568751778360594059323559122001926998892775320459354030780527512388866727013611839711880863892855582012014699037849425270694171535841815498719596485797081372313078564817038261151322390659862387024343817583999641599318095006643691668302915734846777094376407219763986615786471443e-11
-2.51280596005873200716381391816925756925431119985085528520431506341857795050665163467305800870349825202443505904965147133603386647317951825503783905854971934984124501009192154345410076495790045351821693193679748449231946538119279287990244328905269896950014237499889805100874600360300372080705680440193e-31
5.28878126526059042211961572197164134159361524276077765221793403798844012084793708458952051106489725583900824025107607215405374703909169907175178795576876679716962184719331880089688644301531389017937990684829693137674310059553826855014217722901333672512171978077923199323101420619889509311410266445282e-93
-4.93111989952218114411037708547958535049064970400675437426625703411271759121608509177654260333810321114897891516650513950841018901790452633022850097675956067927605564239872555425691913511371577371913058457479468122358354846415177260553864505858297543336840540400974323336544868566961108687414214190763e-278
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Here it appears that we are getting about three times the number of digits of $\pi$ with each iteration.

Let us revisit approximating $\sqrt{2}$ but now look at rationals rather than floating point values.

def g(x): return(x/2+1/x) x=2 for i in srange(10): x=g(x) print(x) 
       
3/2
17/12
577/408
665857/470832
886731088897/627013566048
1572584048032918633353217/1111984844349868137938112
4946041176255201878775086487573351061418968498177/3497379255757941172020\
851852070562919437964212608
489266466344238819545868088398566945584921822586685371455477008985472229\
10968507268117381704646657/345963636159190997653185453890148615173898600\
71988342648187104766246565694525469768325292176831232
478763350177956355033875147816435262639381098519240525465422927625192536\
278777030635238432538459639859433124003263771029921757766826313024689222\
1798809427255174348445597103634783814035090442551297/3385368114944226131\
160489088412764413184597197600430424080424489217455640335520865446091847\
042392283395113030493175270757327077204943610618917073241080260452775055\
121081948254768847591544963982848
458428690947240922822566645595252166921730911625264970188568172074537671\
270953540524180726398577008886911343616394972437715281767167828764577487\
969452842495948702003839208053221469997779237833195077272838504228313099\
156077778147669481592899633555182948656598838967121365018560046135181125\
504905510456807418457335837652057485933007622252777062429707198214146800\
60203467479543923750220952764417/324158036059266107179062099902159258891\
605764527205477244295855476514930407813338323629758918110423709601010054\
367934599364441230238437071808639277664637257090987314791426159312811991\
060429452743544130062958250208034504512010719340758722866368024472407510\
720960223706805134209255718151599546080731623248350096571215092195996031\
67122882578517323407726312472428238351392267283960361495336307712
3/2
17/12
577/408
665857/470832
886731088897/627013566048
1572584048032918633353217/1111984844349868137938112
4946041176255201878775086487573351061418968498177/3497379255757941172020851852070562919437964212608
48926646634423881954586808839856694558492182258668537145547700898547222910968507268117381704646657/34596363615919099765318545389014861517389860071988342648187104766246565694525469768325292176831232
4787633501779563550338751478164352626393810985192405254654229276251925362787770306352384325384596398594331240032637710299217577668263130246892221798809427255174348445597103634783814035090442551297/3385368114944226131160489088412764413184597197600430424080424489217455640335520865446091847042392283395113030493175270757327077204943610618917073241080260452775055121081948254768847591544963982848
45842869094724092282256664559525216692173091162526497018856817207453767127095354052418072639857700888691134361639497243771528176716782876457748796945284249594870200383920805322146999777923783319507727283850422831309915607777814766948159289963355518294865659883896712136501856004613518112550490551045680741845733583765205748593300762225277706242970719821414680060203467479543923750220952764417/32415803605926610717906209990215925889160576452720547724429585547651493040781333832362975891811042370960101005436793459936444123023843707180863927766463725709098731479142615931281199106042945274354413006295825020803450451201071934075872286636802447240751072096022370680513420925571815159954608073162324835009657121509219599603167122882578517323407726312472428238351392267283960361495336307712

Continued fraction for $\pi$

p=pi.n() 
       
print p 
       
3.14159265358979
3.14159265358979
1/(p-3) 
       
7.06251330593105
7.06251330593105
1/(1/(p-3) - 7) 
       
15.9965944066841
15.9965944066841
continued_fraction(p) 
       
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3]
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3]
 
       
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3]
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3]
 
       

Let us use Newton's method to approximate the cube root of 2.

2.^(1/3.) 
       
1.25992104989487
1.25992104989487
def g(x): return(2*x/3+2/(3*x^2)) 
       
g(2) 
       
3/2
3/2
continued_fraction(g(3/2)) 
       
[1; 3, 2, 1, 2]
[1; 3, 2, 1, 2]
continued_fraction(g(35/27)) 
       
[1; 3, 1, 4, 1, 29, 2, 1, 11, 4]
[1; 3, 1, 4, 1, 29, 2, 1, 11, 4]
continued_fraction(2.^(1/3.)) 
       
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 10]
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 10]

Since we don't see patterns in the continued fractions, let us revert to floating point and high accuracy.

R = RealField(1000); R RealNumber=R 
       
2.^(1/3.) 
       
1.2599210498948731647672106072782283505702514647015079800819751121552996\
765139594837293965624362550941543102560356156652593990240406137372284591\
103042693552469606426166250009774745265654803068671854055186892458725167\
641993737096950983827831613991551293136953661839474634485765703031190958\
9598474110598
1.25992104989487316476721060727822835057025146470150798008197511215529967651395948372939656243625509415431025603561566525939902404061373722845911030426935524696064261662500097747452656548030686718540551868924587251676419937370969509838278316139915512931369536618394746344857657030311909589598474110598
continued_fraction(2.^(1/3.)) 
       
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3,
4, 1, 1, 2, 14, 3, 12, 1, 15, 3, 1, 4, 534, 1, 1, 5, 1, 1, 121, 1, 2, 2,
4, 10, 3, 2, 2, 41, 1, 1, 1, 3, 7, 2, 2, 9, 4, 1, 3, 7, 6, 1, 1, 2, 2,
9, 3, 1, 1, 69, 4, 4, 5, 12, 1, 1, 5, 15, 1, 4, 1, 1, 1, 1, 1, 89, 1,
22, 186, 6, 2, 3, 1, 3, 2, 1, 1, 5, 1, 3, 1, 8, 9, 1, 26, 1, 7, 1, 18,
6, 1, 372, 3, 13, 1, 1, 14, 2, 2, 2, 1, 1, 4, 3, 2, 2, 1, 1, 9, 1, 6, 1,
38, 1, 2, 25, 1, 4, 2, 44, 1, 22, 2, 12, 11, 1, 1, 49, 2, 6, 8, 2, 3, 2,
1, 3, 5, 1, 1, 1, 3, 1, 2, 1, 2, 4, 1, 1, 3, 2, 1, 9, 4, 1, 4, 1, 2, 1,
27, 1, 1, 5, 5, 1, 3, 2, 1, 2, 2, 3, 1, 4, 2, 2, 8, 4, 1, 6, 1, 1, 1,
36, 9, 13, 9, 3, 6, 2, 5, 1, 1, 1, 2, 10, 21, 1, 1, 1, 2, 1, 2, 6, 2, 1,
6, 19, 1, 1, 18, 1, 2, 1, 1, 1, 27, 1, 1, 10, 3, 11, 38, 7, 1, 1, 1, 3,
1, 8, 1, 5, 1, 5, 4, 4, 4, 7, 2, 1, 21, 1, 1, 5, 10, 3, 1, 72, 6, 9, 1,
3, 3, 2, 1, 5]
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, 1, 1, 2, 14, 3, 12, 1, 15, 3, 1, 4, 534, 1, 1, 5, 1, 1, 121, 1, 2, 2, 4, 10, 3, 2, 2, 41, 1, 1, 1, 3, 7, 2, 2, 9, 4, 1, 3, 7, 6, 1, 1, 2, 2, 9, 3, 1, 1, 69, 4, 4, 5, 12, 1, 1, 5, 15, 1, 4, 1, 1, 1, 1, 1, 89, 1, 22, 186, 6, 2, 3, 1, 3, 2, 1, 1, 5, 1, 3, 1, 8, 9, 1, 26, 1, 7, 1, 18, 6, 1, 372, 3, 13, 1, 1, 14, 2, 2, 2, 1, 1, 4, 3, 2, 2, 1, 1, 9, 1, 6, 1, 38, 1, 2, 25, 1, 4, 2, 44, 1, 22, 2, 12, 11, 1, 1, 49, 2, 6, 8, 2, 3, 2, 1, 3, 5, 1, 1, 1, 3, 1, 2, 1, 2, 4, 1, 1, 3, 2, 1, 9, 4, 1, 4, 1, 2, 1, 27, 1, 1, 5, 5, 1, 3, 2, 1, 2, 2, 3, 1, 4, 2, 2, 8, 4, 1, 6, 1, 1, 1, 36, 9, 13, 9, 3, 6, 2, 5, 1, 1, 1, 2, 10, 21, 1, 1, 1, 2, 1, 2, 6, 2, 1, 6, 19, 1, 1, 18, 1, 2, 1, 1, 1, 27, 1, 1, 10, 3, 11, 38, 7, 1, 1, 1, 3, 1, 8, 1, 5, 1, 5, 4, 4, 4, 7, 2, 1, 21, 1, 1, 5, 10, 3, 1, 72, 6, 9, 1, 3, 3, 2, 1, 5]
x=2. for i in srange(20): x=g(x) print(x-2.^(1/3.)) 
       
0.2400789501051268352327893927217716494297485352984920199180248878447003\
234860405162706034375637449058456897439643843347406009759593862627715408\
896957306447530393573833749990225254734345196931328145944813107541274832\
358006262903049016172168386008448706863046338160525365514234296968809041\
04015258894019
0.0363752464014231315290856890180679457260448315947883162143211841409966\
197823368125668997338600412021419860402606806310368972722556825590678371\
859920269410493356536796712953188217697308159894291108907776070504237795\
320969225866011979135131348971411669826009301123488328477197259931772004\
003115551903151
0.0010111748468753865051501888920916292735379028973834283332428268721631\
604726870267266377031218199877302954380938879880537780986603184875132894\
409680914409233593372271643666214168818497376321602774314679572645835175\
013587013721895073113463422541580478090055660407942851026957904930512240\
8385904826161769
8.1067105308555988812028773327972363643132461880866942001984713405572088\
773482338849016072472203066097592631629998615470640592860665981987719894\
422421192843510933141986143260283757379566100697873640275030385367426501\
259055220093086055581096273043001191583649762182389840530223116362629549\
0989509601888e-7
5.2160966162166855757859645546163178538305061047628827021654716323361575\
918714806971804912432846727532531077625930372987998923697195215444685241\
727536331064285574737262587002853503215138304328545719469490353754397800\
306232797843740914009767109935411783249870387444981370424827115008384692\
8075236113477e-13
2.1594737155921257867756844852428147591121284375133130469944993003585955\
823617779724586025849637437942540707986871753222630793599212990272798834\
644032399112173371764035701446157662576307372068560871487486262726062239\
911977701262483836016200822518105670355425621582320036543534248846445381\
1106739555418e-25
3.7012848771138205332851150649007809483177983587083478967769964046849592\
519917593422279553385969298868103517699520889509914456766860636221729099\
992690692074865765243255383041510265316212761179146621004697004271040859\
739564475205953839474362966884217885337472768849446138339770400723876021\
5687457955606e-50
1.0873308087593699647968670217995645141243530397068239716551799307842389\
835082165282612715381557067241383952097088541674685085313439861501901364\
456373494955668981565503702425163888157594140900172238823780109481921158\
571681410165109460015135131129266397224870953913972381601023211461258866\
4451217820011e-99
9.3838283579431806233214980586342941737452386520075530929152169848420354\
620843565925077401547549999537065135143583382621420179355614981534996217\
753432348129148452874203400226253949563988007643323965542653721938589117\
999183480735351520931956118033692923357927893418176667443960098183158032\
7919922249338e-199
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
-1.866527237006437757980179089447634339234182892743416049243428679591933\
821951551268908880654195762204719189979860648485248430975042708064789683\
041634407861512468821332276650300547990151971803663022200981592530226236\
481025029591867581610356542250830207621396757708852962238939628457321918\
44403532582089e-301
0.240078950105126835232789392721771649429748535298492019918024887844700323486040516270603437563744905845689743964384334740600975959386262771540889695730644753039357383374999022525473434519693132814594481310754127483235800626290304901617216838600844870686304633816052536551423429696880904104015258894019
0.0363752464014231315290856890180679457260448315947883162143211841409966197823368125668997338600412021419860402606806310368972722556825590678371859920269410493356536796712953188217697308159894291108907776070504237795320969225866011979135131348971411669826009301123488328477197259931772004003115551903151
0.00101117484687538650515018889209162927353790289738342833324282687216316047268702672663770312181998773029543809388798805377809866031848751328944096809144092335933722716436662141688184973763216027743146795726458351750135870137218950731134634225415804780900556604079428510269579049305122408385904826161769
8.10671053085559888120287733279723636431324618808669420019847134055720887734823388490160724722030660975926316299986154706405928606659819877198944224211928435109331419861432602837573795661006978736402750303853674265012590552200930860555810962730430011915836497621823898405302231163626295490989509601888e-7
5.21609661621668557578596455461631785383050610476288270216547163233615759187148069718049124328467275325310776259303729879989236971952154446852417275363310642855747372625870028535032151383043285457194694903537543978003062327978437409140097671099354117832498703874449813704248271150083846928075236113477e-13
2.15947371559212578677568448524281475911212843751331304699449930035859558236177797245860258496374379425407079868717532226307935992129902727988346440323991121733717640357014461576625763073720685608714874862627260622399119777012624838360162008225181056703554256215823200365435342488464453811106739555418e-25
3.70128487711382053328511506490078094831779835870834789677699640468495925199175934222795533859692988681035176995208895099144567668606362217290999926906920748657652432553830415102653162127611791466210046970042710408597395644752059538394743629668842178853374727688494461383397704007238760215687457955606e-50
1.08733080875936996479686702179956451412435303970682397165517993078423898350821652826127153815570672413839520970885416746850853134398615019013644563734949556689815655037024251638881575941409001722388237801094819211585716814101651094600151351311292663972248709539139723816010232114612588664451217820011e-99
9.38382835794318062332149805863429417374523865200755309291521698484203546208435659250774015475499995370651351435833826214201793556149815349962177534323481291484528742034002262539495639880076433239655426537219385891179991834807353515209319561180336929233579278934181766674439600981831580327919922249338e-199
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301
-1.86652723700643775798017908944763433923418289274341604924342867959193382195155126890888065419576220471918997986064848524843097504270806478968304163440786151246882133227665030054799015197180366302220098159253022623648102502959186758161035654225083020762139675770885296223893962845732191844403532582089e-301

It appears that we roughly double the accuracy of the precision at each stage.

 

Experiment with higher roots: 4th root, 5th root etc.

def g(x): return(x-tan(x)) 
       
x=3. for i in srange(20): x=g(x) print(x-pi.n(1000)) 
       
0.0009538894844845668329920272544106090289228855266988266582943843810421\
889353295394310712330056498433831117917322255821253781744673695056146439\
845912804985318804752101353288030712902287523252904033660117589412138661\
791406778236594594845084061125747499184511315343870119469081635092528990\
10223834594556279
-2.893164230127576115595897875535762301615295543160529728080940090902180\
356912840846129881044762965064226173102645853430558249184363373226873908\
179011269706600569053844507169547130662314467637013924911188865212837826\
362076318253838491937832701592857235073031352348287546288911439729282501\
21463749831282e-10
8.0723132460404718265780444757084152736055525580521536648676639435818395\
958010622727634452968598977733842807221506554634817207257829279660871915\
841046486930545255843173723767502938361918368272011569984305221343698542\
240545664572148922486170201003466557015441593670706071478752703238837412\
2798376220430e-30
-1.753366741046227233384030998675880531736427960968791240011987121162803\
342156097313518377020480856485383046106957912737363194625080517570377078\
451772798305632596576566813100782533103797168926929802919536968499679006\
962739375383064490261903853085639834976570324500921336760262502746011533\
37262428580855e-88
1.7967888266622393519739173050128013023527823666944564778367309824044605\
802626277748466280043168593358179261033421709462949362405940681582165101\
277522881187610916812392025365983323253099188844914244057821575478896308\
489996027283957447655039762354393912030360370206959285851647397520003868\
3347559688899e-264
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.000953889484484566832992027254410609028922885526698826658294384381042188935329539431071233005649843383111791732225582125378174467369505614643984591280498531880475210135328803071290228752325290403366011758941213866179140677823659459484508406112574749918451131534387011946908163509252899010223834594556279
-2.89316423012757611559589787553576230161529554316052972808094009090218035691284084612988104476296506422617310264585343055824918436337322687390817901126970660056905384450716954713066231446763701392491118886521283782636207631825383849193783270159285723507303135234828754628891143972928250121463749831282e-10
8.07231324604047182657804447570841527360555255805215366486766394358183959580106227276344529685989777338428072215065546348172072578292796608719158410464869305452558431737237675029383619183682720115699843052213436985422405456645721489224861702010034665570154415936707060714787527032388374122798376220430e-30
-1.75336674104622723338403099867588053173642796096879124001198712116280334215609731351837702048085648538304610695791273736319462508051757037707845177279830563259657656681310078253310379716892692980291953696849967900696273937538306449026190385308563983497657032450092133676026250274601153337262428580855e-88
1.79678882666223935197391730501280130235278236669445647783673098240446058026262777484662800431685933581792610334217094629493624059406815821651012775228811876109168123920253659833232530991888449142440578215754788963084899960272839574476550397623543939120303603702069592858516473975200038683347559688899e-264
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

It appears that we are seeing tripling of the number of digits of accuracy now rather than doubling.

Approximate zero by starting at .1

x=.1 for i in srange(20): x=g(x) print(x) 
       
-0.000334672085450545058080045781111536819004804576442040022208065798032\
112885673870347930480348730914605811375434908526853166815570049728613127\
358010572265944633779386666941998220624385587678554458359766344255328187\
099758359939906396248533527418538900632205735662934128891531380481546865\
305369510596692059
1.2495028026268862538141412669186193197949112036815067920385669148296722\
742992633933418459001000090597387909636253810981881576125626676666422080\
595465945764302129218242816227538479054028381784851560228041785353304539\
381452248714147682698080539291753360446220272114961801679678924251351996\
3175427686553e-11
-6.502651047367412972975887255610604827515285577963798631112393570544785\
739340863437817850680576100295709754705004585633470682736499296369502020\
153462672643210862929529739904938920221132988015900416512947297026074301\
654595441680969068877858015532442652642353528957883176379037606832551924\
39207803476879e-34
9.1653719106489368890419282567772234422322256614731077546638272497111456\
256132065184229465862505095451877629572439217485435116804660180434179793\
529270457552076935406126524189817508996277037262025703178314114281253874\
343767721848735464218380445415551432755765728815475000499644608633477475\
4415442119733e-101
-2.566427631051559648485769248414105021982482238789070566369137901391818\
033926838152278893772605378172962109212318996713602898544195459361980712\
499275296708693210289795094041496429257642190314492299312405705402002094\
181961879304033632854818119038207969600158143614996130445506669291852249\
11277012926101e-301
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
-0.000334672085450545058080045781111536819004804576442040022208065798032112885673870347930480348730914605811375434908526853166815570049728613127358010572265944633779386666941998220624385587678554458359766344255328187099758359939906396248533527418538900632205735662934128891531380481546865305369510596692059
1.24950280262688625381414126691861931979491120368150679203856691482967227429926339334184590010000905973879096362538109818815761256266766664220805954659457643021292182428162275384790540283817848515602280417853533045393814522487141476826980805392917533604462202721149618016796789242513519963175427686553e-11
-6.50265104736741297297588725561060482751528557796379863111239357054478573934086343781785068057610029570975470500458563347068273649929636950202015346267264321086292952973990493892022113298801590041651294729702607430165459544168096906887785801553244265264235352895788317637903760683255192439207803476879e-34
9.16537191064893688904192825677722344223222566147310775466382724971114562561320651842294658625050954518776295724392174854351168046601804341797935292704575520769354061265241898175089962770372620257031783141142812538743437677218487354642183804454155514327557657288154750004996446086334774754415442119733e-101
-2.56642763105155964848576924841410502198248223878907056636913790139181803392683815227889377260537817296210921231899671360289854419545936198071249927529670869321028979509404149642925764219031449229931240570540200209418196187930403363285481811903820796960015814361499613044550666929185224911277012926101e-301
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Starting at 1.0, we still go to 0 very quickly.

x=1. for i in srange(20): x=g(x) print(x) 
       
-0.557407724654902230506974807458360173087250772381520038383946605698861\
397151727289555099965202242983804633821411748166613323554618124558937606\
071684548904439293586043167147908036824613274706955597341640610775535247\
302506796850507041352385144917621481627570027886022450772014016185772130\
673941664322369
0.0659364519248408190359707343907714038678379807793421238379040749276203\
307761807579092417493160759576734288638240013155158445625470776979775882\
703923412093428050829705660356125215452144921053217777332712398478468953\
011682495125534349562003931717159422400025573566761381978238617832117481\
641415235241400
-0.000095721919325085464563299952541794420646547542692884247171198347362\
746924907831849034243892733561425780421099842402532639222395738701169493\
272289940298360538012748141518673583569044486910390596957929886662537486\
269923778552760252482107960364616988770288559928287679712578848026491134\
8392827691987811041
2.9235662597433810057199099681803202128738218438405154013167540271460560\
159798771113997373766987620602453907051631256330475626558487732081712781\
935359298492747986378183110067447982805432564488443692288952083992369751\
851069418536493698498227389085721340249506094586698987167658384644131621\
6170723356139e-13
-8.329473842697096068137345832619703662750380886448370990755176080970803\
131870401069851764713827008139830698466802602486778210271973331850317594\
036364964860873421699007974690894879522209281236345339561676593960933925\
513576229132443704694632317904120722239946244638269370818589167250676185\
85426059299914e-39
1.9263333849623239860358922068735302304042296480242160060470909777064051\
584203932324124853617269147360492716314804488820415742608063784003719117\
659729349949850310545896764323218648090856503994965410337597501226651348\
412921503022876516637510688471851082749075372918822114366228733945111805\
4742333950214e-115
-2.382720489595149904732427066661322495582179524244590931386235512607002\
906365927279437462655572441729972188810635629411973630498212984071078176\
072451865135894121364183854972829319042415516754365668050310562478531949\
032797438011999854595523294617953834153067274186252170810842867938885380\
63390224110438e-345
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000
-0.557407724654902230506974807458360173087250772381520038383946605698861397151727289555099965202242983804633821411748166613323554618124558937606071684548904439293586043167147908036824613274706955597341640610775535247302506796850507041352385144917621481627570027886022450772014016185772130673941664322369
0.0659364519248408190359707343907714038678379807793421238379040749276203307761807579092417493160759576734288638240013155158445625470776979775882703923412093428050829705660356125215452144921053217777332712398478468953011682495125534349562003931717159422400025573566761381978238617832117481641415235241400
-0.0000957219193250854645632999525417944206465475426928842471711983473627469249078318490342438927335614257804210998424025326392223957387011694932722899402983605380127481415186735835690444869103905969579298866625374862699237785527602524821079603646169887702885599282876797125788480264911348392827691987811041
2.92356625974338100571990996818032021287382184384051540131675402714605601597987711139973737669876206024539070516312563304756265584877320817127819353592984927479863781831100674479828054325644884436922889520839923697518510694185364936984982273890857213402495060945866989871676583846441316216170723356139e-13
-8.32947384269709606813734583261970366275038088644837099075517608097080313187040106985176471382700813983069846680260248677821027197333185031759403636496486087342169900797469089487952220928123634533956167659396093392551357622913244370469463231790412072223994624463826937081858916725067618585426059299914e-39
1.92633338496232398603589220687353023040422964802421600604709097770640515842039323241248536172691473604927163148044888204157426080637840037191176597293499498503105458967643232186480908565039949654103375975012266513484129215030228765166375106884718510827490753729188221143662287339451118054742333950214e-115
-2.38272048959514990473242706666132249558217952424459093138623551260700290636592727943746265557244172997218881063562941197363049821298407107817607245186513589412136418385497282931904241551675436566805031056247853194903279743801199985459552329461795383415306727418625217081084286793888538063390224110438e-345
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
x=1.2 for i in srange(20): x=g(x) print(x) 
       
-1.372151622126318935409994236033363956529409306043389279225637262238807\
056761734242520344953281203659630813515379295842497345705222723663237219\
472175571003757076836369881836282097461106049903682666310391376095639168\
468384212313273891575042011322068054742684009721038951973892918582211323\
11164373089921
3.5955721840017473287038885906001349224710965584373282995289753210646878\
232242833578431862039882526048444497228710398761436206778267737756087019\
253896502461889009946466128262987373454199511414406831190754583587901174\
278840779582759443311853703465653344879443151779779683101733204775435413\
9035480595967
3.1075995163813933436313664066860711485788431553590361191672375424936288\
461676252386535668087505802349027433978142922479946886820752721397436879\
608198895339033010124610394345984328675826498501954009668275389586816065\
889555610410643919344504003841130178638805201764399037254946234554277397\
4138353798631
3.1416057530461176241658772380542588221622396862392065894628513802053292\
522951980602900183706928142074164235357678880881356034925743331993129914\
047449757369853870523865613046754913068856371457174046607566086712999712\
706955646665519270624651383115829707985078327586333865786017431338028044\
5467022121020
3.1415926535897924891922729652676512037133828770825351844632382058357653\
198263783039792849510014608597305225212693848754362769557285673777743765\
785082593900759145506474441103497107643291276455183758731320224559067082\
830039039899191702626554112659684252379756091682223497599894539452882554\
5644657956887
3.1415926535897932384626433832795028841971693995153208034750964053073130\
132337541612810936088089140653661489276215354388864538811173857913769585\
675038755814557703264394768706721179861231050969338155030540194853884709\
626669537145252702984732087800378707661554848444111977103231583887136107\
3600096730539
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822308064\
726107003041005697509463621137756343503923341292517260818433264180621906\
114172089731549150963177622692946168023391384256536326712859010291680479\
5656561932307
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
3.1415926535897932384626433832795028841971693993751058209749445923078164\
062862089986280348253421170679821480865132823066470938446095505822317253\
594081284811174502841027019385211055596446229489549303819644288109756659\
334461284756482337867831652712019091456485669234603486104543266482133936\
0726024914127
-1.37215162212631893540999423603336395652940930604338927922563726223880705676173424252034495328120365963081351537929584249734570522272366323721947217557100375707683636988183628209746110604990368266631039137609563916846838421231327389157504201132206805474268400972103895197389291858221132311164373089921
3.59557218400174732870388859060013492247109655843732829952897532106468782322428335784318620398825260484444972287103987614362067782677377560870192538965024618890099464661282629873734541995114144068311907545835879011742788407795827594433118537034656533448794431517797796831017332047754354139035480595967
3.10759951638139334363136640668607114857884315535903611916723754249362884616762523865356680875058023490274339781429224799468868207527213974368796081988953390330101246103943459843286758264985019540096682753895868160658895556104106439193445040038411301786388052017643990372549462345542773974138353798631
3.14160575304611762416587723805425882216223968623920658946285138020532925229519806029001837069281420741642353576788808813560349257433319931299140474497573698538705238656130467549130688563714571740466075660867129997127069556466655192706246513831158297079850783275863338657860174313380280445467022121020
3.14159265358979248919227296526765120371338287708253518446323820583576531982637830397928495100146085973052252126938487543627695572856737777437657850825939007591455064744411034971076432912764551837587313202245590670828300390398991917026265541126596842523797560916822234975998945394528825545644657956887
3.14159265358979323846264338327950288419716939951532080347509640530731301323375416128109360880891406536614892762153543888645388111738579137695856750387558145577032643947687067211798612310509693381550305401948538847096266695371452527029847320878003787076615548484441119771032315838871361073600096730539
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223080647261070030410056975094636211377563435039233412925172608184332641806219061141720897315491509631776226929461680233913842565363267128590102916804795656561932307
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127
R = RealField(200); R RealNumber=R 
       
 
       
x=1.2 for i in srange(20): x=g(x) print(x) 
       
-1.3721516221263189354099942360333639565294093060433892792256
3.5955721840017473287038885906001349224710965584373282995290
3.1075995163813933436313664066860711485788431553590361191672
3.1416057530461176241658772380542588221622396862392065894629
3.1415926535897924891922729652676512037133828770825351844632
3.1415926535897932384626433832795028841971693995153208034751
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
-1.3721516221263189354099942360333639565294093060433892792256
3.5955721840017473287038885906001349224710965584373282995290
3.1075995163813933436313664066860711485788431553590361191672
3.1416057530461176241658772380542588221622396862392065894629
3.1415926535897924891922729652676512037133828770825351844632
3.1415926535897932384626433832795028841971693995153208034751
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
3.1415926535897932384626433832795028841971693993751058209749
plot(sin,-10,10) 
       

Starting at 1.2, we end up going far enough negative that the next iteration is just a little bit more than 3.14, and so the next iterates converge to $\pi$ again.

This means that there is an interval (-a,a) for which, if we start in that interval, we converge immediately to 0.  Outside of that interval, we will jump to a different period of the function.

How do we find the value of a?

plot(2*x-tan(x),(x,-2,2)) 
       
R = RealField(100); R RealNumber=R 
       
plot( 
       
plot(sin(1/x), (x, -1, 1))