roots.rlg 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382
  1. Sun Aug 18 18:03:26 2002 run on Windows
  2. % Tests of the root finding package.
  3. % Author: Stanley L. Kameny (stan_kameny@rand.org)
  4. comment Addition for roots mod 1.95. The function multroot has been
  5. added to the roots package in mod 1.95. This provides the capability
  6. to solve a nest of n polynomials in n variables, provided that each
  7. polynomial either is univariate or introduces a new variable to the
  8. set. The solutions can be either real solutions only, or complex
  9. solutions. All solutions to the new examples, problems 117) and
  10. subsequent, are correct to all digits shown. As in the prior examples,
  11. root order and values should agree exactly with that given here.
  12. comment This test file works only with Reduce version 3.5 and later
  13. and contains examples all of which are solved by roots mod 1.94.
  14. Answers are rounded to the value given by rootacc (default = 6)
  15. unless higher accuracy is needed to separate roots. Format may differ
  16. from that given here, but root order and values should agree exactly.
  17. (Although the function ROOTS may obtain the roots in a different order,
  18. they are sorted into a standard order in mod 1.94 and later.)
  19. In the following, problems 20) and 82) are time consuming and
  20. have been commented out to speed up the test.
  21. The hard examples 111) through 115) almost double the test time
  22. but are necessary to test some logical paths.
  23. A new "hardest" example has been added as example 116). It is
  24. commented out, since it is time consuming, but it is solved by roots
  25. mod 1.94. The time needed to run the three commented-out examples is
  26. almost exactly equal to the time for the rest of the test. Users of
  27. fast computers can uncomment the lines marked with %**%. The three
  28. examples by themselves are contained in the test file rootsxtr.tst.
  29. When answers are produced which require precision increase for
  30. printing out or input of roots, roots functions cause precision
  31. increase to occur. If the precision is already higher than the
  32. default value, a message is printed out warning of the the precision
  33. normally needed for input of those values.$
  34. realroots x;
  35. {x=0}
  36. % To load roots package.
  37. write "This is Roots Package test ", symbolic roots!-mod$
  38. This is Roots Package test Mod 1.96, 30 March 1995.
  39. % Simple root finding.
  40. % 1) multiple real and imaginary roots plus two real roots.
  41. zz:= (x-3)**2*(100x**2+113)**2*(1000000x-10000111)*(x-1);
  42. 8 7 6 5
  43. zz := 10000000000*x - 170001110000*x + 872607770000*x - 1974219158600*x
  44. 4 3 2
  45. + 2833796550200*x - 3810512046359*x + 3119397498913*x
  46. - 2030292260385*x + 1149222756231
  47. roots zz;
  48. {x=1.06301*i,
  49. x=1.06301*i,
  50. x= - 1.06301*i,
  51. x= - 1.06301*i,
  52. x=3.0,
  53. x=3.0,
  54. x=1,
  55. x=10.0001}
  56. %{x=1.06301*i,x=1.06301*i,x=-1.06301*i,x=-1.06301*i,
  57. %x=3.0,x=3.0,x=1,x=10.0001} (rootacc caused rounding to 6 places)
  58. % Accuracy is increased whenever necessary to separate distinct roots.
  59. % 2) accuracy increase to 7 required for two roots.
  60. zz:=(x**2+1)*(x-2)*(1000000x-2000001);
  61. 4 3 2
  62. zz := 1000000*x - 4000001*x + 5000002*x - 4000001*x + 4000002
  63. roots zz;
  64. {x=i,
  65. x= - i,
  66. x=2.0,
  67. x=2.000001}
  68. %{x=i,x= -i,x=2.0,x=2.000001}
  69. % 3) accuracy increase to 8 required.
  70. zz:= (x-3)*(10000000x-30000001);
  71. 2
  72. zz := 10000000*x - 60000001*x + 90000003
  73. roots zz;
  74. {x=3.0,x=3.0000001}
  75. %{x=3.0,x=3.0000001}
  76. % 4) accuracy increase required here to separate repeated root from
  77. % simple root.
  78. zz := (x-3)*(1000000x-3000001)*(x-3)*(1000000x-3241234);
  79. 4 3 2
  80. zz := 2*(500000000000*x - 6120617500000*x + 28085557620617*x
  81. - 57256673223702*x + 43756673585553)
  82. roots zz;
  83. {x=3.0,
  84. x=3.0,
  85. x=3.000001,
  86. x=3.24123}
  87. %{x=3.0,x=3.0,x=3.000001,x=3.24123}
  88. % other simple examples
  89. % 5) five real roots with widely different spacing.
  90. zz:= (x-1)*(10x-11)*(x-1000)*(x-1001)*(x-100000);
  91. 5 4 3 2
  92. zz := 10*x - 1020031*x + 2013152032*x - 1005224243011*x + 2104312111000*x
  93. - 1101100000000
  94. roots zz;
  95. {x=1,
  96. x=1.1,
  97. x=1000.0,
  98. x=1001.0,
  99. x=1.0e+5}
  100. %{x=1,x=1.1,x=1000.0,x=1001.0,x=1.0E+5}
  101. % 6) a cluster of 5 roots in complex plane in vicinity of x=1.
  102. zz:= (x-1)*(10000x**2-20000x+10001)*(10000x**2-20000x+9999);
  103. 5 4 3 2
  104. zz := 100000000*x - 500000000*x + 1000000000*x - 1000000000*x + 499999999*x
  105. - 99999999
  106. roots zz;
  107. {x=0.99,
  108. x=1,
  109. x=1 + 0.01*i,
  110. x=1 - 0.01*i,
  111. x=1.01}
  112. %{x=0.99,x=1,x=1 + 0.01*i,x=1 - 0.01*i,x=1.01}
  113. % 7) four closely spaced real roots.
  114. zz := (x-1)*(100x-101)*(100x-102)*(100x-103);
  115. 4 3 2
  116. zz := 2*(500000*x - 2030000*x + 3090550*x - 2091103*x + 530553)
  117. roots zz;
  118. {x=1,
  119. x=1.01,
  120. x=1.02,
  121. x=1.03}
  122. %{x=1,x=1.01,x=1.02,x=1.03}
  123. % 8) five closely spaced roots, 3 real + 1 complex pair.
  124. zz := (x-1)*(100x-101)*(100x-102)*(100x**2-200x+101);
  125. 5 4 3 2
  126. zz := 2*(500000*x - 2515000*x + 5065100*x - 5105450*x + 2575601*x - 520251)
  127. roots zz;
  128. {x=1,
  129. x=1 + 0.1*i,
  130. x=1 - 0.1*i,
  131. x=1.01,
  132. x=1.02}
  133. %{x=1,x=1 + 0.1*i,x=1 - 0.1*i,x=1.01,x=1.02}
  134. % 9) symmetric cluster of 5 roots, 3 real + 1 complex pair.
  135. zz := (x-2)*(10000x**2-40000x+40001)*(10000x**2-40000x+39999);
  136. 5 4 3 2
  137. zz := 100000000*x - 1000000000*x + 4000000000*x - 8000000000*x
  138. + 7999999999*x - 3199999998
  139. roots zz;
  140. {x=1.99,
  141. x=2.0,
  142. x=2.0 + 0.01*i,
  143. x=2.0 - 0.01*i,
  144. x=2.01}
  145. %{x=1.99,x=2.0,x=2.0 + 0.01*i,x=2.0 - 0.01*i,x=2.01}
  146. % 10) closely spaced real and complex pair.
  147. ss:= (x-2)*(100000000x**2-400000000x+400000001);
  148. 3 2
  149. ss := 100000000*x - 600000000*x + 1200000001*x - 800000002
  150. roots ss;
  151. {x=2.0,x=2.0 + 0.0001*i,x=2.0 - 0.0001*i}
  152. %{x=2.0,x=2.0 + 0.0001*i,x=2.0 - 0.0001*i}
  153. % 11) Zero roots and multiple roots cause no problem.
  154. % Multiple roots are shown when the switch multiroot is on
  155. %(normally on.)
  156. zz:= x*(x-1)**2*(x-4)**3*(x**2+1);
  157. 7 6 5 4 3 2
  158. zz := x*(x - 14*x + 74*x - 186*x + 249*x - 236*x + 176*x - 64)
  159. roots zz;
  160. {x=0,
  161. x=4.0,
  162. x=4.0,
  163. x=4.0,
  164. x=1,
  165. x=1,
  166. x=i,
  167. x= - i}
  168. %{x=0,x=4.0,x=4.0,x=4.0,x=1,x=1,x=i,x= - i}
  169. % 12) nearestroot will find a single root "near" a value, real or
  170. % complex.
  171. nearestroot(zz,2i);
  172. {x=i}
  173. %{x=i}
  174. % More difficult examples.
  175. % Three examples in which root scaling is needed in the complex
  176. % iteration process.
  177. % 13) nine roots, 3 real and 3 complex pairs.
  178. zz:= x**9-45x-2;
  179. 9
  180. zz := x - 45*x - 2
  181. roots zz;
  182. {x= - 1.60371,
  183. x= - 1.13237 + 1.13805*i,
  184. x= - 1.13237 - 1.13805*i,
  185. x= - 0.0444444,
  186. x=0.00555357 + 1.60944*i,
  187. x=0.00555357 - 1.60944*i,
  188. x=1.14348 + 1.13804*i,
  189. x=1.14348 - 1.13804*i,
  190. x=1.61483}
  191. %{x= - 1.60371,x=-1.13237 + 1.13805*i,x=-1.13237 - 1.13805*i,
  192. % x= - 0.0444444,x=0.00555357 + 1.60944*i,x=0.00555357 - 1.60944*i,
  193. % x=1.14348 + 1.13804*i,x=1.14348 - 1.13804*i,x=1.61483}
  194. comment In the next two examples, there are complex roots with
  195. extremely small real parts (new capability in Mod 1.91.);
  196. % 14) nine roots, 1 real and 4 complex pairs.
  197. zz:= x**9-9999x**2-0.01;
  198. 9 2
  199. 100*x - 999900*x - 1
  200. zz := ------------------------
  201. 100
  202. roots zz;
  203. {x= - 3.3584 + 1.61732*i,
  204. x= - 3.3584 - 1.61732*i,
  205. x= - 0.829456 + 3.63408*i,
  206. x= - 0.829456 - 3.63408*i,
  207. x=5.0025e-29 + 0.00100005*i,
  208. x=5.0025e-29 - 0.00100005*i,
  209. x=2.32408 + 2.91431*i,
  210. x=2.32408 - 2.91431*i,
  211. x=3.72754}
  212. %{x=-3.3584 + 1.61732*i,x=-3.3584 - 1.61732*i,
  213. % x=-0.829456 + 3.63408*i,x=-0.829456 - 3.63408*i,
  214. % x=5.0025E-29 + 0.00100005*i,x=5.0025E-29 - 0.00100005*i,
  215. % x=2.32408 + 2.91431*i,x=2.32408 - 2.91431*i,x=3.72754}
  216. comment Rootacc 7 produces 7 place accuracy. Answers will print in
  217. bigfloat format if floating point print >6 digits is not implemented.;
  218. % 15) nine roots, 1 real and 4 complex pairs.
  219. rootacc 7;
  220. 7
  221. zz:= x**9-500x**2-0.001;
  222. 9 2
  223. 1000*x - 500000*x - 1
  224. zz := -------------------------
  225. 1000
  226. roots zz;
  227. {x= - 2.189157 + 1.054242*i,
  228. x= - 2.189157 - 1.054242*i,
  229. x= - 0.5406772 + 2.368861*i,
  230. x= - 0.5406772 - 2.368861*i,
  231. x=1.6e-26 + 0.001414214*i,
  232. x=1.6e-26 - 0.001414214*i,
  233. x=1.514944 + 1.899679*i,
  234. x=1.514944 - 1.899679*i,
  235. x=2.429781}
  236. %{x=-2.189157 + 1.054242*i,x=-2.189157 - 1.054242*i,
  237. % x=-0.5406772 + 2.368861*i,x=-0.5406772 - 2.368861*i,
  238. % x=1.6E-26 + 0.001414214*i,x=1.6E-26 - 0.001414214*i,
  239. % x=1.514944 + 1.899679*i,x=1.514944 - 1.899679*i,x=2.429781}
  240. % the famous Wilkinson "ill-conditioned" polynomial and its family.
  241. % 16) W(6) four real roots plus one complex pair.
  242. zz:= 10000*(for j:=1:6 product(x+j))+27x**5;
  243. 6 5 4 3 2
  244. zz := 10000*x + 210027*x + 1750000*x + 7350000*x + 16240000*x + 17640000*x
  245. + 7200000
  246. roots zz;
  247. {x= - 6.143833,
  248. x= - 4.452438 + 0.02123455*i,
  249. x= - 4.452438 - 0.02123455*i,
  250. x= - 2.950367,
  251. x= - 2.003647,
  252. x= - 0.9999775}
  253. %{x= - 6.143833,x=-4.452438 + 0.02123455*i,x=-4.452438 - 0.02123455*i,
  254. % x= - 2.950367,x= - 2.003647,x= - 0.9999775}
  255. % 17) W(8) 4 real roots plus 2 complex pairs.
  256. zz:= 1000*(for j:=1:8 product(x+j))+2x**7;
  257. 8 7 6 5 4 3
  258. zz := 2*(500*x + 18001*x + 273000*x + 2268000*x + 11224500*x + 33642000*x
  259. 2
  260. + 59062000*x + 54792000*x + 20160000)
  261. roots zz;
  262. {x= - 8.437546,
  263. x= - 6.494828 + 1.015417*i,
  264. x= - 6.494828 - 1.015417*i,
  265. x= - 4.295858 + 0.2815097*i,
  266. x= - 4.295858 - 0.2815097*i,
  267. x= - 2.982725,
  268. x= - 2.000356,
  269. x= - 0.9999996}
  270. %{x= - 8.437546,x=-6.494828 + 1.015417*i,x=-6.494828 - 1.015417*i,
  271. % x=-4.295858 + 0.2815097*i,x=-4.295858 - 0.2815097*i,
  272. % x= - 2.982725,x= - 2.000356,x= - 0.9999996}
  273. % 18) W(10) 6 real roots plus 2 complex pairs.
  274. zz:=1000*(for j:= 1:10 product (x+j))+x**9;
  275. 10 9 8 7 6
  276. zz := 1000*x + 55001*x + 1320000*x + 18150000*x + 157773000*x
  277. 5 4 3 2
  278. + 902055000*x + 3416930000*x + 8409500000*x + 12753576000*x
  279. + 10628640000*x + 3628800000
  280. roots zz;
  281. {x= - 10.80988,
  282. x= - 8.70405 + 1.691061*i,
  283. x= - 8.70405 - 1.691061*i,
  284. x= - 6.046279 + 1.134321*i,
  285. x= - 6.046279 - 1.134321*i,
  286. x= - 4.616444,
  287. x= - 4.075943,
  288. x= - 2.998063,
  289. x= - 2.000013,
  290. x= - 1}
  291. %{x= - 10.80988,x=-8.70405 + 1.691061*i,x=-8.70405 - 1.691061*i,
  292. % x=-6.046279 + 1.134321*i,x=-6.046279 - 1.134321*i,x= - 4.616444,
  293. % x= - 4.075943,x= - 2.998063,x= - 2.000013,x= - 1}
  294. % 19) W(12) 6 real roots plus 3 complex pairs.
  295. zz:= 10000*(for j:=1:12 product(x+j))+4x**11;
  296. 12 11 10 9 8
  297. zz := 4*(2500*x + 195001*x + 6792500*x + 139425000*x + 1873657500*x
  298. 7 6 5
  299. + 17316585000*x + 112475577500*x + 515175375000*x
  300. 4 3 2
  301. + 1643017090000*x + 3535037220000*x + 4828898880000*x
  302. + 3716107200000*x + 1197504000000)
  303. roots zz;
  304. {x= - 13.1895,
  305. x= - 11.02192 + 2.23956*i,
  306. x= - 11.02192 - 2.23956*i,
  307. x= - 7.953917 + 1.948001*i,
  308. x= - 7.953917 - 1.948001*i,
  309. x= - 5.985629 + 0.8094247*i,
  310. x= - 5.985629 - 0.8094247*i,
  311. x= - 4.880956,
  312. x= - 4.007117,
  313. x= - 2.999902,
  314. x= - 2.0,
  315. x= - 1}
  316. %{x= - 13.1895,x=-11.02192 + 2.23956*i,x=-11.02192 - 2.23956*i,
  317. % x=-7.953917 + 1.948001*i,x=-7.953917 - 1.948001*i,
  318. % x=-5.985629 + 0.8094247*i,x=-5.985629 - 0.8094247*i,
  319. % x= - 4.880956,x= - 4.007117,x= - 2.999902,x= - 2.0,x= - 1}
  320. % 20) W(20) 10 real roots plus 5 complex pairs. (The original problem)
  321. % This example is commented out, since it takes significant time without
  322. % being particularly difficult or checking out new paths:
  323. %**% zz:= x**19+10**7*for j:=1:20 product (x+j); roots zz;
  324. %{x= - 20.78881,x=-19.45964 + 1.874357*i,x=-19.45964 - 1.874357*i,
  325. % x=-16.72504 + 2.731577*i,x=-16.72504 - 2.731577*i,
  326. % x=-14.01105 + 2.449466*i,x=-14.01105 - 2.449466*i,
  327. % x=-11.82101 + 1.598621*i,x=-11.82101 - 1.598621*i,
  328. % x=-10.12155 + 0.6012977*i,x=-10.12155 - 0.6012977*i,
  329. % x= - 8.928803,x= - 8.006075,x= - 6.999746,x= - 6.000006,
  330. % x= - 5.0,x= - 4.0,x= - 3.0,x= - 2.0,x= - 1}
  331. rootacc 6;
  332. 6
  333. % 21) Finding one of a cluster of 8 roots.
  334. zz:= (10**16*(x-1)**8-1);
  335. 8 7 6
  336. zz := 10000000000000000*x - 80000000000000000*x + 280000000000000000*x
  337. 5 4 3
  338. - 560000000000000000*x + 700000000000000000*x - 560000000000000000*x
  339. 2
  340. + 280000000000000000*x - 80000000000000000*x + 9999999999999999
  341. nearestroot(zz,2);
  342. {x=1.01}
  343. %{x=1.01}
  344. % 22) Six real roots spaced 0.01 apart.
  345. c := 100;
  346. c := 100
  347. zz:= (x-1)*for i:=1:5 product (c*x-(c+i));
  348. 6 5 4 3
  349. zz := 40*(250000000*x - 1537500000*x + 3939625000*x - 5383556250*x
  350. 2
  351. + 4137919435*x - 1696170123*x + 289681938)
  352. roots zz;
  353. {x=1,
  354. x=1.01,
  355. x=1.02,
  356. x=1.03,
  357. x=1.04,
  358. x=1.05}
  359. %{x=1,x=1.01,x=1.02,x=1.03,x=1.04,x=1.05}
  360. % 23) Six real roots spaced 0.001 apart.
  361. c := 1000;
  362. c := 1000
  363. zz:= (x-1)*for i:=1:5 product (c*x-(c+i));
  364. 6 5 4
  365. zz := 40*(25000000000000*x - 150375000000000*x + 376877125000000*x
  366. 3 2
  367. - 503758505625000*x + 378762766881850*x - 151883516888703*x
  368. + 25377130631853)
  369. roots zz;
  370. {x=1,
  371. x=1.001,
  372. x=1.002,
  373. x=1.003,
  374. x=1.004,
  375. x=1.005}
  376. %{x=1,x=1.001,x=1.002,x=1.003,x=1.004,x=1.005}
  377. % 24) Five real roots spaced 0.0001 apart.
  378. c := 10000;
  379. c := 10000
  380. zz:= (x-1)*for i:=1:4 product (c*x-(c+i));
  381. 5 4 3
  382. zz := 8*(1250000000000000*x - 6251250000000000*x + 12505000437500000*x
  383. 2
  384. - 12507501312562500*x + 6255001312625003*x - 1251250437562503)
  385. roots zz;
  386. {x=1,
  387. x=1.0001,
  388. x=1.0002,
  389. x=1.0003,
  390. x=1.0004}
  391. %{x=1,x=1.0001,x=1.0002,x=1.0003,x=1.0004}
  392. % 25) A cluster of 9 roots, 5 real, 2 complex pairs; spacing 0.1.
  393. zz:= (x-1)*(10**8*(x-1)**8-1);
  394. 9 8 7 6
  395. zz := 100000000*x - 900000000*x + 3600000000*x - 8400000000*x
  396. 5 4 3 2
  397. + 12600000000*x - 12600000000*x + 8400000000*x - 3600000000*x
  398. + 899999999*x - 99999999
  399. roots zz;
  400. {x=0.9,
  401. x=0.929289 + 0.0707107*i,
  402. x=0.929289 - 0.0707107*i,
  403. x=1,
  404. x=1 + 0.1*i,
  405. x=1 - 0.1*i,
  406. x=1.07071 + 0.0707107*i,
  407. x=1.07071 - 0.0707107*i,
  408. x=1.1}
  409. %{x=0.9,x=0.929289 + 0.0707107*i,x=0.929289 - 0.0707107*i,
  410. % x=1,x=1 + 0.1*i,x=1 - 0.1*i,
  411. % x=1.07071 + 0.0707107*i,x=1.07071 - 0.0707107*i,x=1.1}
  412. % 26) Same, but with spacing 0.01.
  413. zz:= (x-1)*(10**16*(x-1)**8-1);
  414. 9 8 7
  415. zz := 10000000000000000*x - 90000000000000000*x + 360000000000000000*x
  416. 6 5 4
  417. - 840000000000000000*x + 1260000000000000000*x - 1260000000000000000*x
  418. 3 2
  419. + 840000000000000000*x - 360000000000000000*x + 89999999999999999*x
  420. - 9999999999999999
  421. roots zz;
  422. {x=0.99,
  423. x=0.992929 + 0.00707107*i,
  424. x=0.992929 - 0.00707107*i,
  425. x=1,
  426. x=1 + 0.01*i,
  427. x=1 - 0.01*i,
  428. x=1.00707 + 0.00707107*i,
  429. x=1.00707 - 0.00707107*i,
  430. x=1.01}
  431. %{x=0.99,x=0.992929 + 0.00707107*i,x=0.992929 - 0.00707107*i,
  432. % x=1,x=1 + 0.01*i,x=1 - 0.01*i,
  433. % x=1.00707 + 0.00707107*i,x=1.00707 - 0.00707107*i,x=1.01}
  434. % 27) Spacing reduced to 0.001.
  435. zz:= (x-1)*(10**24*(x-1)**8-1);
  436. 9 8
  437. zz := 1000000000000000000000000*x - 9000000000000000000000000*x
  438. 7 6
  439. + 36000000000000000000000000*x - 84000000000000000000000000*x
  440. 5 4
  441. + 126000000000000000000000000*x - 126000000000000000000000000*x
  442. 3 2
  443. + 84000000000000000000000000*x - 36000000000000000000000000*x
  444. + 8999999999999999999999999*x - 999999999999999999999999
  445. roots zz;
  446. {x=0.999,
  447. x=0.999293 + 0.000707107*i,
  448. x=0.999293 - 0.000707107*i,
  449. x=1,
  450. x=1 + 0.001*i,
  451. x=1 - 0.001*i,
  452. x=1.00071 + 0.000707107*i,
  453. x=1.00071 - 0.000707107*i,
  454. x=1.001}
  455. %{x=0.999,x=0.999293 + 0.000707107*i,x=0.999293 - 0.000707107*i,
  456. % x=1,x=1 + 0.001*i,x=1 - 0.001*i,
  457. % x=1.00071 + 0.000707107*i,x=1.00071 - 0.000707107*i,x=1.001}
  458. % 28) Eight roots divided into two clusters.
  459. zz:= (10**8*(x-1)**4-1)*(10**8*(x+1)**4-1);
  460. 8 6 4
  461. zz := 10000000000000000*x - 40000000000000000*x + 59999999800000000*x
  462. 2
  463. - 40000001200000000*x + 9999999800000001
  464. roots zz;
  465. {x= - 0.99,
  466. x=0.99,
  467. x= - 1 - 0.01*i,
  468. x=1 + 0.01*i,
  469. x= - 1 + 0.01*i,
  470. x=1 - 0.01*i,
  471. x= - 1.01,
  472. x=1.01}
  473. %{x= - 0.99,x=0.99, x=-1 - 0.01*i,x=1 + 0.01*i,
  474. % x=-1 + 0.01*i,x=1 - 0.01*i,x= - 1.01,x=1.01}
  475. % 29) A cluster of 8 roots in a different configuration.
  476. zz:= (10**8*(x-1)**4-1)*(10**8*(100x-102)**4-1);
  477. 8 7
  478. zz := 1000000000000000000000000*x - 8080000000000000000000000*x
  479. 6 5
  480. + 28562400000000000000000000*x - 57694432000000000000000000*x
  481. 4 3
  482. + 72836160149999999900000000*x - 58848320599199999600000000*x
  483. 2
  484. + 29716320897575999400000000*x - 8574560597551679600000000*x
  485. + 1082432149175678300000001
  486. roots zz;
  487. {x=0.99,
  488. x=1 + 0.01*i,
  489. x=1 - 0.01*i,
  490. x=1.01,
  491. x=1.0199,
  492. x=1.02 + 0.0001*i,
  493. x=1.02 - 0.0001*i,
  494. x=1.0201}
  495. %{x=0.99,x=1 + 0.01*i,x=1 - 0.01*i,x=1.01,
  496. % x=1.0199,x=1.02 + 0.0001*i,x=1.02 - 0.0001*i,x=1.0201}
  497. % 30) A cluster of 8 complex roots.
  498. zz:= ((10x-1)**4+1)*((10x+1)**4+1);
  499. 8 6 4 2
  500. zz := 4*(25000000*x - 1000000*x + 20000*x + 200*x + 1)
  501. roots zz;
  502. {x= - 0.0292893 - 0.0707107*i,
  503. x=0.0292893 + 0.0707107*i,
  504. x= - 0.0292893 + 0.0707107*i,
  505. x=0.0292893 - 0.0707107*i,
  506. x= - 0.170711 - 0.0707107*i,
  507. x=0.170711 + 0.0707107*i,
  508. x= - 0.170711 + 0.0707107*i,
  509. x=0.170711 - 0.0707107*i}
  510. %{x=-0.0292893 - 0.0707107*i,x=0.0292893 + 0.0707107*i,
  511. % x=-0.0292893 + 0.0707107*i,x=0.0292893 - 0.0707107*i,
  512. % x=-0.170711 - 0.0707107*i,x=0.170711 + 0.0707107*i,
  513. % x=-0.170711 + 0.0707107*i,x=0.170711 - 0.0707107*i}
  514. comment In these examples, accuracy increase is required to separate a
  515. repeated root from a simple root.;
  516. % 31) Using allroots;
  517. zz:= (x-4)*(x-3)**2*(1000000x-3000001);
  518. 4 3 2
  519. zz := 1000000*x - 13000001*x + 63000010*x - 135000033*x + 108000036
  520. roots zz;
  521. {x=3.0,
  522. x=3.0,
  523. x=3.000001,
  524. x=4.0}
  525. %{x=3.0,x=3.0,x=3.000001,x=4.0}
  526. % 32) Using realroots;
  527. realroots zz;
  528. {x=3.0,
  529. x=3.0,
  530. x=3.000001,
  531. x=4.0}
  532. %{x=3.0,x=3.0,x=3.000001,x=4.0}
  533. comment Tests of new capabilities in mod 1.87 for handling complex
  534. polynomials and polynomials with very small imaginary parts or very
  535. small real roots. A few real examples are shown, just to demonstrate
  536. that these still work.;
  537. % 33) A trivial complex case (but degrees 1 and 2 are special cases);
  538. zz:= x-i;
  539. zz := - i + x
  540. roots zz;
  541. {x=i}
  542. %{x=i}
  543. % 34) Real case.
  544. zz:= y-7;
  545. zz := y - 7
  546. roots zz;
  547. {y=7.0}
  548. %{y=7.0}
  549. % 35) Roots with small imaginary parts (new capability);
  550. zz := 10**16*(x**2-2x+1)+1;
  551. 2
  552. zz := 10000000000000000*x - 20000000000000000*x + 10000000000000001
  553. roots zz;
  554. {x=1 + 0.00000001*i,x=1 - 0.00000001*i}
  555. %{x=1 + 0.00000001*i,x=1 - 0.00000001*i}
  556. % 36) One real, one complex root.
  557. zz:=(x-9)*(x-5i-7);
  558. 2
  559. zz := - 5*i*x + 45*i + x - 16*x + 63
  560. roots zz;
  561. {x=9.0,x=7.0 + 5.0*i}
  562. %{x=9.0,x=7.0 + 5.0*i}
  563. % 37) Three real roots.
  564. zz:= (x-1)*(x-2)*(x-3);
  565. 3 2
  566. zz := x - 6*x + 11*x - 6
  567. roots zz;
  568. {x=1,x=2.0,x=3.0}
  569. %{x=1,x=2.0,x=3.0}
  570. % 38) 2 real + 1 imaginary root.
  571. zz:=(x**2-8)*(x-5i);
  572. 2 3
  573. zz := - 5*i*x + 40*i + x - 8*x
  574. roots zz;
  575. {x= - 2.82843,x=2.82843,x=5.0*i}
  576. %{x= - 2.82843,x=2.82843,x=5.0*i}
  577. % 39) 2 complex roots.
  578. zz:= (x-1-2i)*(x+2+3i);
  579. 2
  580. zz := i*x - 7*i + x + x + 4
  581. roots zz;
  582. {x= - 2.0 - 3.0*i,x=1 + 2.0*i}
  583. %{x=-2.0 - 3.0*i,x=1 + 2.0*i}
  584. % 40) 2 irrational complex roots.
  585. zz:= x**2+(3+2i)*x+7i;
  586. 2
  587. zz := 2*i*x + 7*i + x + 3*x
  588. roots zz;
  589. {x= - 3.14936 + 0.212593*i,x=0.149358 - 2.21259*i}
  590. %{x=-3.14936 + 0.21259*i,x=0.149358 - 2.21259*i}
  591. % 41) 2 complex roots of very different magnitudes with small imaginary
  592. % parts.
  593. zz:= x**2+(1000000000+12i)*x-1000000000;
  594. 2
  595. zz := 12*i*x + x + 1000000000*x - 1000000000
  596. roots zz;
  597. {x= - 1.0e+9 - 12.0*i,x=1 - 0.000000012*i}
  598. %{x=-1.0E+9 - 12.0*i,x=1 - 0.000000012*i}
  599. % 42) Multiple real and complex roots cause no difficulty, provided
  600. % that input is given in integer or rational form, (or if in decimal
  601. % fraction format, with switch rounded off or adjprec on and
  602. % coefficients input explicitly,) so that polynomial is stored exactly.
  603. zz :=(x**2-2i*x+5)**3*(x-2i)*(x-11/10)**2;
  604. 8 7 6 5 4
  605. zz := ( - 800*i*x + 1760*i*x - 6768*i*x + 12760*i*x - 25018*i*x
  606. 3 2 9 8
  607. + 39600*i*x - 46780*i*x + 55000*i*x - 30250*i + 100*x - 220*x
  608. 7 6 5 4 3 2
  609. - 779*x + 1980*x - 9989*x + 19580*x - 28269*x + 38500*x - 21175*x)
  610. /100
  611. roots zz;
  612. {x= - 1.44949*i,
  613. x= - 1.44949*i,
  614. x= - 1.44949*i,
  615. x=3.44949*i,
  616. x=3.44949*i,
  617. x=3.44949*i,
  618. x=1.1,
  619. x=1.1,
  620. x=2.0*i}
  621. %{x=-1.44949*i, x=-1.44949*i, x=-1.44949*i,
  622. % x=3.44949*i, x=3.44949*i, x=3.44949*i, x=1.1, x=1.1, x=2.0*i}
  623. % 42a) would have failed in roots Mod 1.93 and previously (bug)
  624. realroots zz;
  625. {x=1.1,x=1.1}
  626. %{x=1.1,x=1.1}
  627. % 43) 2 real, 2 complex roots.
  628. zz:= (x**2-4)*(x**2+3i*x+5i);
  629. 3 2 4 2
  630. zz := 3*i*x + 5*i*x - 12*i*x - 20*i + x - 4*x
  631. roots zz;
  632. {x= - 2.0,
  633. x=2.0,
  634. x= - 1.2714 + 0.466333*i,
  635. x=1.2714 - 3.46633*i}
  636. %{x= - 2.0,x=2.0,x=-1.2714 + 0.466333*i,x=1.2714 - 3.46633*i}
  637. % 44) 4 complex roots.
  638. zz:= x**4+(0.000001i)*x-16;
  639. 4
  640. i*x + 1000000*x - 16000000
  641. zz := -----------------------------
  642. 1000000
  643. roots zz;
  644. {x= - 2.0 - 0.0000000625*i,
  645. x= - 2.0*i,
  646. x=2.0*i,
  647. x=2.0 - 0.0000000625*i}
  648. %{x=-2.0 - 0.0000000625*i,x=-2.0*i,x=2.0*i,x=2.0 - 0.0000000625*i}
  649. % 45) 2 real, 2 complex roots.
  650. zz:= (x**2-4)*(x**2+2i*x+8);
  651. 3 4 2
  652. zz := 2*i*x - 8*i*x + x + 4*x - 32
  653. roots zz;
  654. {x= - 2.0,
  655. x=2.0,
  656. x= - 4.0*i,
  657. x=2.0*i}
  658. %{x= - 2.0,x=2.0,x=-4.0*i,x=2.0*i}
  659. % 46) Using realroots to find only real roots.
  660. realroots zz;
  661. {x= - 2.0,x=2.0}
  662. %{x= - 2.0,x=2.0}
  663. % 47) Same example, applying nearestroot to find a single root.
  664. zz:= (x**2-4)*(x**2+2i*x+8);
  665. 3 4 2
  666. zz := 2*i*x - 8*i*x + x + 4*x - 32
  667. nearestroot(zz,1);
  668. {x=2.0}
  669. %{x=2.0}
  670. % 48) Same example, but focusing on imaginary point.
  671. nearestroot(zz,i);
  672. {x=2.0*i}
  673. %{x=2.0*i}
  674. % 49) The seed parameter can be complex also.
  675. nearestroot(zz,1+i);
  676. {x=2.0*i}
  677. %{x=2.0*i}
  678. % 50) One more nearestroot example. Nearest root to real point may be
  679. % complex.
  680. zz:= (x**2-4)*(x**2-i);
  681. 2 4 2
  682. zz := - i*x + 4*i + x - 4*x
  683. roots zz;
  684. {x= - 2.0,
  685. x=2.0,
  686. x= - 0.707107 - 0.707107*i,
  687. x=0.707107 + 0.707107*i}
  688. %{x= - 2.0,x=2.0,x=-0.707107 - 0.707107*i,x=0.707107 + 0.707107*i}
  689. nearestroot (zz,1);
  690. {x=0.707107 + 0.707107*i}
  691. %{X=0.707107 + 0.707107*i}
  692. % 51) 1 real root plus 5 complex roots.
  693. zz:=(x**3-3i*x**2-5x+9)*(x**3-8);
  694. 5 2 6 4 3
  695. zz := - 3*i*x + 24*i*x + x - 5*x + x + 40*x - 72
  696. roots zz;
  697. {x= - 1 + 1.73205*i,
  698. x= - 1 - 1.73205*i,
  699. x=2.0,
  700. x= - 2.41613 + 1.19385*i,
  701. x=0.981383 - 0.646597*i,
  702. x=1.43475 + 2.45274*i}
  703. %{x=-1 + 1.73205*i,x=-1 - 1.73205*i,x=2.0,
  704. % x=-2.41613 + 1.19385*i,x=0.981383 - 0.646597*i,x=1.43475 + 2.45274*i}
  705. nearestroot(zz,1);
  706. {x=0.981383 + 0.646597*i}
  707. %{x=0.981383 - 0.646597*i}
  708. % 52) roots can be computed to any accuracy desired, eg. (note that the
  709. % imaginary part of the second root is truncated because of its size,
  710. % and that the imaginary part of a complex root is never polished away,
  711. % even if it is smaller than the accuracy would require.)
  712. zz := x**3+10**(-20)*i*x**2+8;
  713. 2 3
  714. i*x + 100000000000000000000*x + 800000000000000000000
  715. zz := ---------------------------------------------------------
  716. 100000000000000000000
  717. rootacc 12;
  718. 12
  719. roots zz;
  720. {x= - 2.0 - 3.33333333333e-21*i,x=1 - 1.73205080757*i,x=1 + 1.73205080757*i}
  721. rootacc 6;
  722. 6
  723. %{x=-2.0 - 3.33333333333E-21*i,x=1 - 1.73205080757*i,
  724. % x=1 + 1.73205080757*i}
  725. % 53) Precision of 12 required to find small imaginary root,
  726. % but standard accuracy can be used.
  727. zz := x**2+123456789i*x+1;
  728. 2
  729. zz := 123456789*i*x + x + 1
  730. roots zz;
  731. {x= - 1.23457e+8*i,x=0.0000000081*i}
  732. %{x=-1.23457E+8*i,x=0.0000000081*i}
  733. % 54) Small real root is found with root 10*18 times larger(new).
  734. zz := (x+1)*(x**2+123456789*x+1);
  735. 3 2
  736. zz := x + 123456790*x + 123456790*x + 1
  737. roots zz;
  738. {x= - 1.23457e+8,x= - 1,x= - 0.0000000081}
  739. %{x= - 1.23457E+8,x= - 1,x= - 0.0000000081}
  740. % 55) 2 complex, 3 real irrational roots.
  741. ss := (45*x**2+(-10i+12)*x-10i)*(x**3-5x**2+1);
  742. 4 3 2 5 4 3
  743. ss := - 10*i*x + 40*i*x + 50*i*x - 10*i*x - 10*i + 45*x - 213*x - 60*x
  744. 2
  745. + 45*x + 12*x
  746. roots ss;
  747. {x= - 0.429174,
  748. x=0.469832,
  749. x=4.95934,
  750. x= - 0.448056 - 0.19486*i,
  751. x=0.18139 + 0.417083*i}
  752. %{x= - 0.429174,x=0.469832,x=4.95934,
  753. % x=-0.448056 - 0.19486*i,x=0.18139 + 0.417083*i}
  754. % 56) Complex polynomial with floating coefficients.
  755. zz := x**2+1.2i*x+2.3i+6.7;
  756. 2
  757. 12*i*x + 23*i + 10*x + 67
  758. zz := ----------------------------
  759. 10
  760. roots zz;
  761. {x= - 0.427317 + 2.09121*i,x=0.427317 - 3.29121*i}
  762. %{x=-0.427317 + 2.09121*i,x=0.427317 - 3.29121*i}
  763. % 56a) multiple roots will be found if coefficients read in exactly.
  764. % Exact read-in will occur unless dmode is rounded or complex-rounded.
  765. zz := x**3 + (1.09 - 2.4*i)*x**2 + (-1.44 - 2.616*i)*x + -1.5696;
  766. 2 3 2
  767. - 6000*i*x - 6540*i*x + 2500*x + 2725*x - 3600*x - 3924
  768. zz := -------------------------------------------------------------
  769. 2500
  770. roots zz;
  771. {x=1.2*i,x=1.2*i,x= - 1.09}
  772. %{x=1.2*i,x=1.2*i,x= - 1.09}
  773. % 57) Realroots, isolater and rlrootno accept 1, 2 or 3 arguments: (new)
  774. zz:= for j:=-1:3 product (x-j);
  775. 4 3 2
  776. zz := x*(x - 5*x + 5*x + 5*x - 6)
  777. rlrootno zz;
  778. 5
  779. % 5
  780. realroots zz;
  781. {x=0,
  782. x= - 1,
  783. x=1,
  784. x=2.0,
  785. x=3.0}
  786. %{x=0,x= -1,x=1,x=2.0,x=3.0}
  787. rlrootno(zz,positive);
  788. 3
  789. %positive selects positive, excluding 0.
  790. % 3
  791. rlrootno(zz,negative);
  792. 1
  793. %negative selects negative, excluding 0.
  794. % 1
  795. realroots(zz,positive);
  796. {x=1,x=2.0,x=3.0}
  797. %{x=1,x=2.0,x=3.0}
  798. rlrootno(zz,-1.5,2);
  799. 4
  800. %the format with 3 arguments selects a range.
  801. % 4
  802. realroots(zz,-1.5,2);
  803. {x=0,x= - 1,x=1,x=2.0}
  804. %the range is inclusive, except that:
  805. %{x=0,x= - 1,x=1,x=2.0}
  806. % A specific limit b may be excluded by using exclude b. Also, the
  807. % limits infinity and -infinity can be specified.
  808. realroots(zz,exclude 0,infinity);
  809. {x=1,x=2.0,x=3.0}
  810. % equivalent to realroots(zz,positive).
  811. %{x=1,x=2.0,x=3.0}
  812. rlrootno(zz,-infinity,exclude 0);
  813. 1
  814. % equivalent to rlrootno(zz,negative).
  815. % 1
  816. rlrootno(zz,-infinity,0);
  817. 2
  818. % 2
  819. rlrootno(zz,infinity,-infinity);
  820. 5
  821. %equivalent to rlrootno zz; (order of limits does not matter.)
  822. % 5
  823. realroots(zz,1,infinity);
  824. {x=1,x=2.0,x=3.0}
  825. % finds all real roots >= 1.
  826. %{x=1,x=2.0,x=3.0}
  827. realroots(zz,1,positive);
  828. {x=2.0,x=3.0}
  829. % finds all real roots > 1.
  830. %{x=2.0,x=3.0}
  831. % 57a) Bug corrected in mod 1.94. (handling of rational limits)
  832. zz := (x-1/3)*(x-1/5)*(x-1/7)*(x-1/11);
  833. 4 3 2
  834. 1155*x - 886*x + 236*x - 26*x + 1
  835. zz := --------------------------------------
  836. 1155
  837. realroots(zz,1/11,exclude(1/3));
  838. {x=0.0909091,x=0.142857,x=0.2}
  839. %{x=0.0909091,x=0.142857,x=0.2}
  840. realroots(zz,exclude(1/11),1/3);
  841. {x=0.142857,x=0.2,x=0.333333}
  842. %{x=0.142857,x=0.2,x=0.333333}
  843. % New capabilities added in mod 1.88.
  844. % 58) 3 complex roots, with two separated by very small real difference.
  845. zz :=(x+i)*(x+10**8i)*(x+10**8i+1);
  846. 2 3 2
  847. zz := 200000001*i*x + 100000001*i*x - 10000000000000000*i + x + x
  848. - 10000000200000000*x - 100000000
  849. roots zz;
  850. {x= - 1 - 1.0e+8*i,x= - 1.0e+8*i,x= - i}
  851. %{x=-1 - 1.0E+8*i,x=-1.0E+8*i,x= - i}
  852. % 59) Real polynomial with two complex roots separated by very small
  853. % imaginary part.
  854. zz:= (10**14x+123456789000000+i)*(10**14x+123456789000000-i);
  855. 2
  856. zz := 10000000000000000000000000000*x + 24691357800000000000000000000*x
  857. + 15241578750190521000000000001
  858. roots zz;
  859. {x= - 1.23457 + 1.0e-14*i,x= - 1.23457 - 1.0e-14*i}
  860. %{x=-1.23457 + 1.0E-14*i,x=-1.23457 - 1.0E-14*i}
  861. % 60) Real polynomial with two roots extremely close together.
  862. zz:= (x+2)*(10**10x+12345678901)*(10**10x+12345678900);
  863. 3 2
  864. zz := 100*(1000000000000000000*x + 4469135780100000000*x
  865. + 6462429435342508889*x + 3048315750285017778)
  866. roots zz;
  867. {x= - 2.0,x= - 1.2345678901,x= - 1.23456789}
  868. %{x= - 2.0,x= - 1.2345678901,x= - 1.23456789}
  869. % 61) Real polynomial with multiple root extremely close to simple root.
  870. zz:= (x-12345678/10000000)*(x-12345679/10000000)**2;
  871. 3 2
  872. zz := (500000000000000000000*x - 1851851800000000000000*x
  873. + 2286236726108825000000*x - 940838132549050755399)/500000000000000000\
  874. 000
  875. roots zz;
  876. {x=1.2345679,x=1.2345679,x=1.2345678}
  877. %{x=1.2345679,x=1.2345679,x=1.2345678}
  878. % 62) Similar problem using realroots.
  879. zz:=(x-2**30/10**8)**2*(x-(2**30+1)/10**8);
  880. 3 2
  881. zz := (610351562500000000*x - 19660800006103515625*x + 211106232664064000000*x
  882. - 755578637962830675968)/610351562500000000
  883. realroots zz;
  884. {x=10.73741824,x=10.73741824,x=10.73741825}
  885. %{x=10.73741824,x=10.73741824,x=10.73741825}
  886. % 63) Three complex roots with small real separation between two.
  887. zz:= (x-i)*(x-1-10**8i)*(x-2-10**8i);
  888. 2 3 2
  889. zz := - 200000001*i*x + 300000003*i*x + 9999999999999998*i + x - 3*x
  890. - 10000000199999998*x + 300000000
  891. roots zz;
  892. {x=i,x=1 + 1.0e+8*i,x=2.0 + 1.0e+8*i}
  893. %{x=i,x=1 + 1.0E+8*i,x=2.0 + 1.0E+8*i}
  894. % 64) Use of nearestroot to isolate one of the close roots.
  895. nearestroot(zz,10**8i+99/100);
  896. {x=1 + 1.0e+8*i}
  897. %{x=1 + 1.0E+8*i}
  898. % 65) Slightly more complicated example with close complex roots.
  899. zz:= (x-i)*(10**8x-1234-10**12i)*(10**8x-1233-10**12i);
  900. 2
  901. zz := 2*( - 100005000000000000000*i*x + 1233623350000000*i*x
  902. 3 2
  903. + 499999999999999999239239*i + 5000000000000000*x - 123350000000*x
  904. - 500099999999999999239239*x + 1233500000000000)
  905. roots zz;
  906. {x=i,x=0.00001233 + 10000.0*i,x=0.00001234 + 10000.0*i}
  907. %{x=i,x=0.00001233 + 10000.0*i,x=0.00001234 + 10000.0*i}
  908. % 66) Four closely spaced real roots with varying spacings.
  909. zz:= (x-1+1/10**7)*(x-1+1/10**8)*(x-1)*(x-1-1/10**7);
  910. 4 3
  911. zz := (10000000000000000000000*x - 39999999900000000000000*x
  912. 2
  913. + 59999999699999900000000*x - 39999999699999800000001*x
  914. + 9999999899999900000001)/10000000000000000000000
  915. roots zz;
  916. {x=0.9999999,
  917. x=0.99999999,
  918. x=1,
  919. x=1.0000001}
  920. %{x=0.9999999,x=0.99999999,x=1,x=1.0000001}
  921. % 67) Complex pair plus two close real roots.
  922. zz:= (x**2+1)*(x-12345678/10000000)*(x-12345679/10000000);
  923. 4 3 2
  924. zz := (50000000000000*x - 123456785000000*x + 126207888812681*x
  925. - 123456785000000*x + 76207888812681)/50000000000000
  926. roots zz;
  927. {x=i,
  928. x= - i,
  929. x=1.2345678,
  930. x=1.2345679}
  931. %{x=i,x= - i,x=1.2345678,x=1.2345679}
  932. % 68) Same problem using realroots to find only real roots.
  933. realroots zz;
  934. {x=1.2345678,x=1.2345679}
  935. %{x=1.2345678,x=1.2345679}
  936. % The switch ratroot causes output to be given in rational form.
  937. % 69) Two complex roots with output in rational form.
  938. on ratroot,complex;
  939. zz:=x**2-(5i+1)*x+1;
  940. 2
  941. zz := x - (1 + 5*i)*x + 1
  942. sss:= roots zz;
  943. 346859 - 1863580*i 482657 + 2593180*i
  944. sss := {x=--------------------,x=--------------------}
  945. 10000000 500000
  946. % 346859 - 1863580*i 482657 + 2593180*i
  947. %sss := {x=--------------------,x=--------------------}
  948. % 10000000 500000
  949. % With roots in rational form, mkpoly can be used to reconstruct a
  950. % polynomial.
  951. zz1 := mkpoly sss;
  952. 2
  953. zz1 := 5000000000000*x - (4999999500000 + 25000010000000*i)*x
  954. + 5000012308763 - 2110440*i
  955. % 2
  956. %zz1 := 5000000000000*x - (4999999500000 + 25000010000000*i)*x
  957. %
  958. % + 5000012308763 - 2110440*i
  959. % Finding the roots of the new polynomial zz1.
  960. rr:= roots zz1;
  961. 346859 - 1863580*i 482657 + 2593180*i
  962. rr := {x=--------------------,x=--------------------}
  963. 10000000 500000
  964. % 346859 - 1863580*i 482657 + 2593180*i
  965. %rr := {x=--------------------,x=--------------------}
  966. % 10000000 500000
  967. % The roots are stable to the extent that rr=ss, although zz1 and
  968. % zz may differ.
  969. zz1 - zz;
  970. 2
  971. 4999999999999*x - (4999999499999 + 25000009999995*i)*x
  972. + 5000012308762 - 2110440*i
  973. % 2
  974. %4999999999999*x - (4999999499999 + 25000009999995*i)*x
  975. %
  976. % + 5000012308762 - 2110440*i
  977. % 70) Same type of problem in which roots are found exactly.
  978. zz:=(x-10**8+i)*(x-10**8-i)*(x-10**8+3i/2)*(x-i);
  979. 4 3 2
  980. zz := (2*x - (600000000 - i)*x + 60000000000000005*x
  981. - (2000000000000000800000000 + 29999999999999999*i)*x
  982. + 30000000000000003 + 2000000000000000200000000*i)/2
  983. rr := roots zz;
  984. rr := {x=100000000 + i,
  985. x=100000000 - i,
  986. x=i,
  987. 200000000 - 3*i
  988. x=-----------------}
  989. 2
  990. % 4 3 2
  991. %zz := (2*x - (600000000 - i)*x + 60000000000000005*x
  992. %
  993. % - (2000000000000000800000000 + 29999999999999999*i)*x
  994. %
  995. % + (30000000000000003 + 2000000000000000200000000*i))/2
  996. %rr := {x=100000000 + i,x=100000000 - i,x=i,
  997. %
  998. % 200000000 - 3*i
  999. % x=-----------------}
  1000. % 2
  1001. % Reconstructing a polynomial from the roots.
  1002. ss := mkpoly rr;
  1003. 4 3 2
  1004. ss := 2*x - (600000000 - i)*x + 60000000000000005*x
  1005. - (2000000000000000800000000 + 29999999999999999*i)*x + 30000000000000003
  1006. + 2000000000000000200000000*i
  1007. % 4 3 2
  1008. %ss := 2*x - (600000000 - i)*x + 60000000000000005*x
  1009. %
  1010. % - (2000000000000000800000000 + 29999999999999999*i)*x
  1011. %
  1012. % + (30000000000000003 + 2000000000000000200000000*i)
  1013. % In this case, the same polynomial is obtained.
  1014. ss - num zz;
  1015. 0
  1016. % 0
  1017. % 71) Finding one of the complex roots using nearestroot.
  1018. nearestroot(zz,10**8-2i);
  1019. 200000000 - 3*i
  1020. {x=-----------------}
  1021. 2
  1022. % 200000000 - 3*I
  1023. %{x=-----------------}
  1024. % 2
  1025. % Finding the other complex root using nearestroot.
  1026. nearestroot(zz,10**8+2i);
  1027. {x=100000000 + i}
  1028. %{x=100000000 + I}
  1029. % 72) A realroots problem which requires accuracy increase to avoid
  1030. % confusion of two roots.
  1031. zz:=(x+1)*(10000000x-19999999)*(1000000x-2000001)*(x-2);
  1032. 4 3 2
  1033. zz := 10000000000000*x - 50000009000000*x + 60000026999999*x
  1034. + 40000000000001*x - 80000035999998
  1035. realroots zz;
  1036. {x= - 1,
  1037. 19999999
  1038. x=----------,
  1039. 10000000
  1040. x=2,
  1041. 2000001
  1042. x=---------}
  1043. 1000000
  1044. % 19999999 2000001
  1045. % {x=-1,x=----------,x=2,x=---------}
  1046. % 10000000 1000000
  1047. % 73) Without the accuracy increase, this example would produce the
  1048. % obviously incorrect answer 2.
  1049. realroots(zz,3/2,exclude 2);
  1050. 19999999
  1051. {x=----------}
  1052. 10000000
  1053. % 19999999
  1054. % {x=----------}
  1055. % 10000000
  1056. % Rlrootno also gives the correct answer in this case.
  1057. rlrootno(zz,3/2,exclude 2);
  1058. 1
  1059. % 1
  1060. % 74) Roots works equally well in this problem.
  1061. rr := roots zz;
  1062. rr := {x= - 1,
  1063. 19999999
  1064. x=----------,
  1065. 10000000
  1066. x=2,
  1067. 2000001
  1068. x=---------}
  1069. 1000000
  1070. % 19999999 2000001
  1071. %rr := {x= - 1,x=----------,x=2,x=---------}
  1072. % 10000000 1000000
  1073. % 75) The function getroot is convenient for obtaining the value of a
  1074. % root.
  1075. rr1 := getroot(1,rr);
  1076. rr1 := -1
  1077. % 19999999
  1078. % rr1 := ----------
  1079. % 10000000
  1080. % 76) For example, the value can be used as an argument to nearestroot.
  1081. nearestroot(zz,rr1);
  1082. {x= - 1}
  1083. % 19999999
  1084. % {x=----------}
  1085. % 10000000
  1086. comment New capabilities added to Mod 1.90 for avoiding floating point
  1087. exceptions and exceeding iteration limits.;
  1088. % 77) This and the next example would previously have aborted because
  1089. %of exceeding iteration limits:
  1090. off ratroot;
  1091. zz := x**16 - 900x**15 -2;
  1092. 16 15
  1093. zz := x - 900*x - 2
  1094. roots zz;
  1095. {x= - 0.665423,
  1096. x= - 0.607902 + 0.270641*i,
  1097. x= - 0.607902 - 0.270641*i,
  1098. x= - 0.44528 + 0.494497*i,
  1099. x= - 0.44528 - 0.494497*i,
  1100. x= - 0.205664 + 0.632867*i,
  1101. x= - 0.205664 - 0.632867*i,
  1102. x=0.069527 + 0.661817*i,
  1103. x=0.069527 - 0.661817*i,
  1104. x=0.332711 + 0.57633*i,
  1105. x=0.332711 - 0.57633*i,
  1106. x=0.538375 + 0.391176*i,
  1107. x=0.538375 - 0.391176*i,
  1108. x=0.650944 + 0.138369*i,
  1109. x=0.650944 - 0.138369*i,
  1110. x=900.0}
  1111. %{x= - 0.665423,x=-0.607902 + 0.270641*i,x=-0.607902 - 0.270641*i,
  1112. % x=-0.44528 + 0.494497*i, x=-0.44528 - 0.494497*i,
  1113. % x=-0.205664 + 0.632867*i,x=-0.205664 - 0.632867*i,
  1114. % x=0.069527 + 0.661817*i,x=0.069527 - 0.661817*i,
  1115. % x=0.332711 + 0.57633*i,x=0.332711 - 0.57633*i,
  1116. % x=0.538375 + 0.391176*i,x=0.538375 - 0.391176*i,
  1117. % x=0.650944 + 0.138369*i,x=0.650944 - 0.138369*i,x=900.0}
  1118. % 78) a still harder example.
  1119. zz := x**30 - 900x**29 - 2;
  1120. 30 29
  1121. zz := x - 900*x - 2
  1122. roots zz;
  1123. {x= - 0.810021,
  1124. x= - 0.791085 + 0.174125*i,
  1125. x= - 0.791085 - 0.174125*i,
  1126. x= - 0.735162 + 0.340111*i,
  1127. x= - 0.735162 - 0.340111*i,
  1128. x= - 0.644866 + 0.490195*i,
  1129. x= - 0.644866 - 0.490195*i,
  1130. x= - 0.524417 + 0.617362*i,
  1131. x= - 0.524417 - 0.617362*i,
  1132. x= - 0.379447 + 0.715665*i,
  1133. x= - 0.379447 - 0.715665*i,
  1134. x= - 0.216732 + 0.780507*i,
  1135. x= - 0.216732 - 0.780507*i,
  1136. x= - 0.04388 + 0.808856*i,
  1137. x= - 0.04388 - 0.808856*i,
  1138. x=0.131027 + 0.799383*i,
  1139. x=0.131027 - 0.799383*i,
  1140. x=0.299811 + 0.752532*i,
  1141. x=0.299811 - 0.752532*i,
  1142. x=0.454578 + 0.67049*i,
  1143. x=0.454578 - 0.67049*i,
  1144. x=0.588091 + 0.557094*i,
  1145. x=0.588091 - 0.557094*i,
  1146. x=0.694106 + 0.417645*i,
  1147. x=0.694106 - 0.417645*i,
  1148. x=0.767663 + 0.258664*i,
  1149. x=0.767663 - 0.258664*i,
  1150. x=0.805322 + 0.0875868*i,
  1151. x=0.805322 - 0.0875868*i,
  1152. x=900.0}
  1153. %{x= - 0.810021,x=-0.791085 + 0.174125*i,x=-0.791085 - 0.174125*i,
  1154. % x=-0.735162 + 0.340111*i,x=-0.735162 - 0.340111*i,
  1155. % x=-0.644866 + 0.490195*i,x=-0.644866 - 0.490195*i,
  1156. % x=-0.524417 + 0.617362*i,x=-0.524417 - 0.617362*i,
  1157. % x=-0.379447 + 0.715665*i,x=-0.379447 - 0.715665*i,
  1158. % x=-0.216732 + 0.780507*i,x=-0.216732 - 0.780507*i,
  1159. % x=-0.04388 + 0.808856*i,x=-0.04388 - 0.808856*i,
  1160. % x=0.131027 + 0.799383*i,x=0.131027 - 0.799383*i,
  1161. % x=0.299811 + 0.752532*i,x=0.299811 - 0.752532*i,
  1162. % x=0.454578 + 0.67049*i,x=0.454578 - 0.67049*i,
  1163. % x=0.588091 + 0.557094*i,x=0.588091 - 0.557094*i,
  1164. % x=0.694106 + 0.417645*i,x=0.694106 - 0.417645*i,
  1165. % x=0.767663 + 0.258664*i,x=0.767663 - 0.258664*i,
  1166. % x=0.805322 + 0.0875868*i,x=0.805322 - 0.0875868*i,x=900.0}
  1167. % 79) this deceptively simple example previously caused floating point
  1168. % overflows on some systems:
  1169. aa := x**6 - 4*x**3 + 2;
  1170. 6 3
  1171. aa := x - 4*x + 2
  1172. realroots aa;
  1173. {x=0.836719,x=1.50579}
  1174. %{x=0.836719,x=1.50579}
  1175. % 80) a harder problem, which would have failed on almost all systems:
  1176. rr := x**16 - 90000x**15 - x**2 -2;
  1177. 16 15 2
  1178. rr := x - 90000*x - x - 2
  1179. realroots rr;
  1180. {x= - 0.493299,x=90000.0}
  1181. %{x= - 0.493299,x=90000.0}
  1182. % 81) this example would have failed because of floating point
  1183. % exceptions on almost all computer systems.
  1184. rr := x**30 - 9*10**10*x**29 - 2;
  1185. 30 29
  1186. rr := x - 90000000000*x - 2
  1187. realroots rr;
  1188. {x= - 0.429188,x=9.0e+10}
  1189. %{x= - 0.429188,x=9.0E+10}
  1190. % 82) a test of allroot on this example.
  1191. % This example is commented out because it takes significant time
  1192. % without breaking new ground.
  1193. %**% roots rr;
  1194. %{x= - 0.429188,
  1195. % x=-0.419154 + 0.092263*i,x=-0.419154 - 0.092263*i,
  1196. % x=-0.389521 + 0.180211*i,x=-0.389521 - 0.180211*i,
  1197. % x=-0.341674 + 0.259734*i,x=-0.341674 - 0.259734*i,
  1198. % x=-0.277851 + 0.327111*i,x=-0.277851 - 0.327111*i,
  1199. % x=-0.201035 + 0.379193*i,x=-0.201035 - 0.379193*i,
  1200. % x=-0.11482 + 0.413544*i,x=-0.11482 - 0.413544*i,
  1201. % x=-0.0232358 + 0.428559*i,x=-0.0232358 - 0.428559*i,
  1202. % x=0.0694349 + 0.423534*i,x=0.0694349 - 0.423534*i,
  1203. % x=0.158859 + 0.398706*i,x=0.158859 - 0.398706*i,
  1204. % x=0.240855 + 0.355234*i,x=0.240855 - 0.355234*i,
  1205. % x=0.311589 + 0.295153*i,x=0.311589 - 0.295153*i,
  1206. % x=0.367753 + 0.22127*i,x=0.367753 - 0.22127*i,
  1207. % x=0.406722 + 0.13704*i,x=0.406722 - 0.13704*i,
  1208. % x=0.426672 + 0.0464034*i,x=0.426672 - 0.0464034*i,x=9.0E+10}
  1209. % 83) test of starting point for iteration: no convergence if good
  1210. % real starting point is not found.
  1211. zz := x**30 -9*10**12x**29 -2;
  1212. 30 29
  1213. zz := x - 9000000000000*x - 2
  1214. firstroot zz;
  1215. {x= - 0.36617}
  1216. %{x= - 0.36617}
  1217. % 84) a case in which there are no real roots and good imaginary
  1218. % starting point must be used or roots cannot be found.
  1219. zz:= 9x**16 - x**5 +1;
  1220. 16 5
  1221. zz := 9*x - x + 1
  1222. roots zz;
  1223. {x= - 0.866594 + 0.193562*i,
  1224. x= - 0.866594 - 0.193562*i,
  1225. x= - 0.697397 + 0.473355*i,
  1226. x= - 0.697397 - 0.473355*i,
  1227. x= - 0.510014 + 0.716449*i,
  1228. x= - 0.510014 - 0.716449*i,
  1229. x= - 0.161318 + 0.87905*i,
  1230. x= - 0.161318 - 0.87905*i,
  1231. x=0.182294 + 0.828368*i,
  1232. x=0.182294 - 0.828368*i,
  1233. x=0.459373 + 0.737443*i,
  1234. x=0.459373 - 0.737443*i,
  1235. x=0.748039 + 0.494348*i,
  1236. x=0.748039 - 0.494348*i,
  1237. x=0.845617 + 0.142879*i,
  1238. x=0.845617 - 0.142879*i}
  1239. %{x=-0.866594 + 0.193562*i,x=-0.866594 - 0.193562*i,
  1240. % x=-0.697397 + 0.473355*i,x=-0.697397 - 0.473355*i,
  1241. % x=-0.510014 + 0.716449*i,x=-0.510014 - 0.716449*i,
  1242. % x=-0.161318 + 0.87905*i,x=-0.161318 - 0.87905*i,
  1243. % x=0.182294 + 0.828368*i,x=0.182294 - 0.828368*i,
  1244. % x=0.459373 + 0.737443*i,x=0.459373 - 0.737443*i,
  1245. % x=0.748039 + 0.494348*i,x=0.748039 - 0.494348*i,
  1246. % x=0.845617 + 0.142879*i,x=0.845617 - 0.142879*i}
  1247. % 85) five complex roots.
  1248. zz := x**5 - x**3 + i;
  1249. 5 3
  1250. zz := x - x + i
  1251. roots zz;
  1252. {x= - 1.16695 - 0.217853*i,
  1253. x= - 0.664702 + 0.636663*i,
  1254. x= - 0.83762*i,
  1255. x=0.664702 + 0.636663*i,
  1256. x=1.16695 - 0.217853*i}
  1257. %{x=-1.16695 - 0.217853*i,x=-0.664702 + 0.636663*i,x=-0.83762*i,
  1258. % x=0.664702 + 0.636663*i,x=1.16695 - 0.217853*i}
  1259. % Additional capabilities in Mod 1.91.
  1260. % 86) handling of polynomial with huge or infinitesimal coefficients.
  1261. precision reset;
  1262. 12
  1263. on rounded;
  1264. *** Domain mode complex changed to complex-rounded
  1265. precision reset;
  1266. 12
  1267. % so that the system will start this example in floating point. Rounded
  1268. % is on so that the polynomial won't fill the page!
  1269. zz:= 1.0e-500x**3+x**2+x;
  1270. *** ROUNDBF turned on to increase accuracy
  1271. 2
  1272. zz := x*(1.0e-500*x + x + 1)
  1273. roots zz;
  1274. {x=0,x= - 1.0e+500,x= - 1}
  1275. off rounded;
  1276. *** Domain mode complex-rounded changed to complex
  1277. % rounded not normally needed for roots.
  1278. %{x=0,x= - 1.0E+500,x= - 1}
  1279. off roundbf;
  1280. comment Switch roundbf will have been turned on in the last example in
  1281. most computer systems. This will inhibit the use of hardware floating
  1282. point unless roundbf is turned off.
  1283. Polynomials which make use of powergcd substitution and cascaded
  1284. solutions.
  1285. Uncomplicated cases.;
  1286. switch powergcd;
  1287. % introduced here to verify that same answers are
  1288. % obtained with and without employing powergcd strategy. Roots are
  1289. % found faster for applicable cases when !*powergcd=t (default state.)
  1290. % 87) powergcd done at the top level.
  1291. zz := x**12-5x**9+1;
  1292. 12 9
  1293. zz := x - 5*x + 1
  1294. roots zz;
  1295. {x= - 0.783212 + 0.276071*i,
  1296. x=0.152522 - 0.816316*i,
  1297. x=0.63069 + 0.540246*i,
  1298. x= - 0.783212 - 0.276071*i,
  1299. x=0.152522 + 0.816316*i,
  1300. x=0.63069 - 0.540246*i,
  1301. x= - 0.424222 + 0.734774*i,
  1302. x= - 0.424222 - 0.734774*i,
  1303. x=0.848444,
  1304. x= - 0.85453 + 1.48009*i,
  1305. x= - 0.85453 - 1.48009*i,
  1306. x=1.70906}
  1307. %{x=-0.783212 + 0.276071*i,x=0.152522 - 0.816316*i,
  1308. % x=0.63069 + 0.540246*i,x=-0.783212 - 0.276071*i,
  1309. % x=0.152522 + 0.816316*i,x=0.63069 - 0.540246*i,
  1310. % x=-0.424222 + 0.734774*i,x=-0.424222 - 0.734774*i,x=0.848444,
  1311. % x=-0.85453 + 1.48009*i,x=-0.85453 - 1.48009*i,x=1.70906}
  1312. off powergcd;
  1313. roots zz;
  1314. {x= - 0.85453 + 1.48009*i,
  1315. x= - 0.85453 - 1.48009*i,
  1316. x= - 0.783212 + 0.276071*i,
  1317. x= - 0.783212 - 0.276071*i,
  1318. x= - 0.424222 + 0.734774*i,
  1319. x= - 0.424222 - 0.734774*i,
  1320. x=0.152522 + 0.816316*i,
  1321. x=0.152522 - 0.816316*i,
  1322. x=0.63069 + 0.540246*i,
  1323. x=0.63069 - 0.540246*i,
  1324. x=0.848444,
  1325. x=1.70906}
  1326. on powergcd;
  1327. %{x=-0.85453 + 1.48009*i,x=-0.85453 - 1.48009*i,
  1328. % x=-0.783212 + 0.276071*i,x=-0.783212 - 0.276071*i,
  1329. % x=-0.424222 + 0.734774*i,x=-0.424222 - 0.734774*i,
  1330. % x=0.152522 + 0.816316*i,x=0.152522 - 0.816316*i,
  1331. % x=0.63069 + 0.540246*i,x=0.63069 - 0.540246*i,x=0.848444,x=1.70906}
  1332. % 88) powergcd done after square free factoring.
  1333. zz := (x-1)**2*zz;
  1334. 14 13 12 11 10 9 2
  1335. zz := x - 2*x + x - 5*x + 10*x - 5*x + x - 2*x + 1
  1336. roots zz;
  1337. {x=1,
  1338. x=1,
  1339. x= - 0.783212 + 0.276071*i,
  1340. x=0.152522 - 0.816316*i,
  1341. x=0.63069 + 0.540246*i,
  1342. x= - 0.783212 - 0.276071*i,
  1343. x=0.152522 + 0.816316*i,
  1344. x=0.63069 - 0.540246*i,
  1345. x= - 0.424222 + 0.734774*i,
  1346. x= - 0.424222 - 0.734774*i,
  1347. x=0.848444,
  1348. x= - 0.85453 + 1.48009*i,
  1349. x= - 0.85453 - 1.48009*i,
  1350. x=1.70906}
  1351. %{x=1,x=1,
  1352. % x=-0.783212 + 0.276071*i,x=0.152522 - 0.816316*i,
  1353. % x=0.63069 + 0.540246*i,x=-0.783212 - 0.276071*i,
  1354. % x=0.152522 + 0.816316*i,x=0.63069 - 0.540246*i,
  1355. % x=-0.424222 + 0.734774*i,x=-0.424222 - 0.734774*i,x=0.848444,
  1356. % x=-0.85453 + 1.48009*i,x=-0.85453 - 1.48009*i,x=1.70906}
  1357. off powergcd;
  1358. roots zz;
  1359. {x=1,
  1360. x=1,
  1361. x= - 0.85453 + 1.48009*i,
  1362. x= - 0.85453 - 1.48009*i,
  1363. x= - 0.783212 + 0.276071*i,
  1364. x= - 0.783212 - 0.276071*i,
  1365. x= - 0.424222 + 0.734774*i,
  1366. x= - 0.424222 - 0.734774*i,
  1367. x=0.152522 + 0.816316*i,
  1368. x=0.152522 - 0.816316*i,
  1369. x=0.63069 + 0.540246*i,
  1370. x=0.63069 - 0.540246*i,
  1371. x=0.848444,
  1372. x=1.70906}
  1373. on powergcd;
  1374. %{x=1,x=1,
  1375. % x=-0.85453 + 1.48009*i,x=-0.85453 - 1.48009*i,
  1376. % x=-0.783212 + 0.276071*i,x=-0.783212 - 0.276071*i,
  1377. % x=-0.424222 + 0.734774*i,x=-0.424222 - 0.734774*i,
  1378. % x=0.152522 + 0.816316*i,x=0.152522 - 0.816316*i,
  1379. % x=0.63069 + 0.540246*i,x=0.63069 - 0.540246*i,
  1380. % x=0.848444,x=1.70906}
  1381. % 89) powergcd done after separation into real and complex polynomial.
  1382. zz := x**5-i*x**4+x**3-i*x**2+x-i;
  1383. 5 4 3 2
  1384. zz := x - i*x + x - i*x + x - i
  1385. roots zz;
  1386. {x= - 0.5 - 0.866025*i,
  1387. x=0.5 + 0.866025*i,
  1388. x= - 0.5 + 0.866025*i,
  1389. x=0.5 - 0.866025*i,
  1390. x=i}
  1391. %{x=-0.5 - 0.866025*i,x=0.5 + 0.866025*i,
  1392. % x=-0.5 + 0.866025*i,x=0.5 - 0.866025*i,x=i}
  1393. off powergcd;
  1394. roots zz;
  1395. {x= - 0.5 + 0.866025*i,
  1396. x= - 0.5 - 0.866025*i,
  1397. x=0.5 + 0.866025*i,
  1398. x=0.5 - 0.866025*i,
  1399. x=i}
  1400. on powergcd;
  1401. %{x=-0.5 + 0.866025*i,x=-0.5 - 0.866025*i,
  1402. % x=0.5 + 0.866025*i,x=0.5 - 0.866025*i,x=i}
  1403. % Cases where root separation requires accuracy and/or precision
  1404. % increase. In some examples we get excess accuracy, but it is hard
  1405. % avoid this and still get all roots separated.
  1406. % 90) accuracy increase required to separate close roots;
  1407. let x=y**2;
  1408. zz:= (x-3)*(100000000x-300000001);
  1409. 4 2
  1410. zz := 100000000*y - 600000001*y + 900000003
  1411. roots zz;
  1412. {y= - 1.732050808,
  1413. y=1.732050808,
  1414. y= - 1.73205081,
  1415. y=1.73205081}
  1416. %{y= - 1.732050808,y=1.732050808,y= - 1.73205081,y=1.73205081}
  1417. off powergcd;
  1418. roots zz;
  1419. {y= - 1.73205081,
  1420. y= - 1.732050808,
  1421. y=1.732050808,
  1422. y=1.73205081}
  1423. on powergcd;
  1424. %{y= - 1.73205081,y= - 1.732050808,y=1.732050808,y=1.73205081}
  1425. % 91) roots to be separated are on different square free factors.
  1426. zz:= (x-3)**2*(10000000x-30000001);
  1427. 6 4 2
  1428. zz := 10000000*y - 90000001*y + 270000006*y - 270000009
  1429. roots zz;
  1430. {y= - 1.73205081,
  1431. y= - 1.73205081,
  1432. y=1.73205081,
  1433. y=1.73205081,
  1434. y= - 1.73205084,
  1435. y=1.73205084}
  1436. %{y= - 1.73205081,y= - 1.73205081,y=1.73205081,y=1.73205081,
  1437. % y= - 1.73205084,y=1.73205084}
  1438. off powergcd;
  1439. roots zz;
  1440. {y= - 1.73205081,
  1441. y= - 1.73205081,
  1442. y=1.73205081,
  1443. y=1.73205081,
  1444. y= - 1.73205084,
  1445. y=1.73205084}
  1446. on powergcd;
  1447. %{y= - 1.73205081,y= - 1.73205081,y=1.73205081,y=1.73205081,
  1448. % y= - 1.73205084,y=1.73205084}
  1449. % 91a) A new capability for nearestroot:
  1450. nearestroot(zz,1.800000000001);
  1451. *** precision increased to 13
  1452. {y=1.732050836436}
  1453. % should find the root to 13 places.
  1454. %{y=1.732050836436}
  1455. % 92) roots must be separated in the complex polynomial factor only.
  1456. zz :=(y+1)*(x+10**8i)*(x+10**8i+1);
  1457. 5 4 3 2
  1458. zz := y + y + (1 + 200000000*i)*y + (1 + 200000000*i)*y
  1459. - (10000000000000000 - 100000000*i)*y - (10000000000000000 - 100000000*i)
  1460. roots zz;
  1461. {y= - 1,
  1462. y= - 7071.067777 + 7071.067847*i,
  1463. y=7071.067777 - 7071.067847*i,
  1464. y= - 7071.067812 + 7071.067812*i,
  1465. y=7071.067812 - 7071.067812*i}
  1466. %{y= - 1,
  1467. % y=-7071.067777 + 7071.067847*i,y=7071.067777 - 7071.067847*i,
  1468. % y=-7071.067812 + 7071.067812*i,y=7071.067812 - 7071.067812*i}
  1469. % 93)
  1470. zz := (x-2)**2*(1000000x-2000001)*(y-1);
  1471. 7 6 5 4 3
  1472. zz := 1000000*y - 1000000*y - 6000001*y + 6000001*y + 12000004*y
  1473. 2
  1474. - 12000004*y - 8000004*y + 8000004
  1475. roots zz;
  1476. {y= - 1.4142136,
  1477. y= - 1.4142136,
  1478. y=1.4142136,
  1479. y=1.4142136,
  1480. y= - 1.4142139,
  1481. y=1,
  1482. y=1.4142139}
  1483. %{y= - 1.4142136,y= - 1.4142136,y=1.4142136,y=1.4142136,
  1484. % y= - 1.4142139,y=1,y=1.4142139}
  1485. % 94)
  1486. zz := (x-2)*(10000000x-20000001);
  1487. 4 2
  1488. zz := 10000000*y - 40000001*y + 40000002
  1489. roots zz;
  1490. {y= - 1.41421356,
  1491. y=1.41421356,
  1492. y= - 1.4142136,
  1493. y=1.4142136}
  1494. %{y= - 1.41421356 ,y=1.41421356 ,y= - 1.4142136,y=1.4142136}
  1495. % 95)
  1496. zz := (x-3)*(10000000x-30000001);
  1497. 4 2
  1498. zz := 10000000*y - 60000001*y + 90000003
  1499. roots zz;
  1500. {y= - 1.73205081,
  1501. y=1.73205081,
  1502. y= - 1.73205084,
  1503. y=1.73205084}
  1504. %{y= - 1.73205081 ,y=1.73205081 ,y= - 1.73205084 ,y=1.73205084}
  1505. % 96)
  1506. zz := (x-9)**2*(1000000x-9000001);
  1507. 6 4 2
  1508. zz := 1000000*y - 27000001*y + 243000018*y - 729000081
  1509. roots zz;
  1510. {y= - 3.0,
  1511. y= - 3.0,
  1512. y=3.0,
  1513. y=3.0,
  1514. y= - 3.00000017,
  1515. y=3.00000017}
  1516. %{y= - 3.0,y= - 3.0,y=3.0,y=3.0,y= - 3.00000017,y=3.00000017}
  1517. % 97)
  1518. zz := (x-3)**2*(1000000x-3000001);
  1519. 6 4 2
  1520. zz := 1000000*y - 9000001*y + 27000006*y - 27000009
  1521. roots zz;
  1522. {y= - 1.7320508,
  1523. y= - 1.7320508,
  1524. y=1.7320508,
  1525. y=1.7320508,
  1526. y= - 1.7320511,
  1527. y=1.7320511}
  1528. %{y= - 1.7320508,y= - 1.7320508,y=1.7320508,y=1.7320508,
  1529. % y= - 1.7320511,y=1.7320511}
  1530. % 98) the accuracy of the root sqrt 5 depends upon another close root.
  1531. % Although one of the factors is given in decimal notation, it is not
  1532. % necessary to turn rounded on.
  1533. rootacc 10;
  1534. 10
  1535. % using rootacc to specify the minumum desired accuracy.
  1536. zz := (y^2-5)*(y-2.2360679775);
  1537. 3 2
  1538. 400000000*y - 894427191*y - 2000000000*y + 4472135955
  1539. zz := ---------------------------------------------------------
  1540. 400000000
  1541. % in this case, adding one place to the root near sqrt 5 causes a
  1542. % required increase of 4 places in accuracy of the root at sqrt 5.
  1543. roots zz;
  1544. *** precision increased to 14
  1545. {y= - 2.236067977,y=2.2360679774998,y=2.2360679775}
  1546. %{y= - 2.236067977,y=2.2360679774998,y=2.2360679775}
  1547. realroots zz;
  1548. {y= - 2.236067977,y=2.2360679774998,y=2.2360679775}
  1549. % should get the same answer from realroots.
  1550. %{y= - 2.2360679775,y=2.2360679774998,y=2.2360679775}
  1551. % 99) The same thing also happens when the root near sqrt 5 is on a
  1552. % different square-free factor.
  1553. zz := (y^2-5)^2*(y-2.2360679775);
  1554. 5 4 3 2
  1555. zz := (400000000*y - 894427191*y - 4000000000*y + 8944271910*y
  1556. + 10000000000*y - 22360679775)/400000000
  1557. roots zz;
  1558. {y= - 2.236067977,
  1559. y= - 2.236067977,
  1560. y=2.2360679774998,
  1561. y=2.2360679774998,
  1562. y=2.2360679775}
  1563. %{y= - 2.236067977,y= - 2.236067977,y=2.2360679774998,
  1564. % y=2.2360679774998,y=2.2360679775}
  1565. realroots zz;
  1566. {y= - 2.236067977,
  1567. y= - 2.236067977,
  1568. y=2.2360679774998,
  1569. y=2.2360679774998,
  1570. y=2.2360679775}
  1571. % realroots handles this case also.
  1572. %{y= - 2.236067977,y= - 2.236067977,y=2.2360679774998,y=2.2360679774998,
  1573. % y=2.2360679775}
  1574. % 100)
  1575. rootacc 6;
  1576. 6
  1577. zz := (y-i)*(x-2)*(1000000x-2000001);
  1578. zz :=
  1579. 5 4 3 2
  1580. 1000000*y - 1000000*i*y - 4000001*y + 4000001*i*y + 4000002*y - 4000002*i
  1581. roots zz;
  1582. {y= - 1.4142136,
  1583. y=1.4142136,
  1584. y= - 1.4142139,
  1585. y=1.4142139,
  1586. y=i}
  1587. %{y= - 1.4142136,y=1.4142136,y= - 1.4142139,y=1.4142139,y=i}
  1588. % 101) this example requires accuracy 15.
  1589. zz:= (y-2)*(100000000000000y-200000000000001);
  1590. 2
  1591. zz := 100000000000000*y - 400000000000001*y + 400000000000002
  1592. roots zz;
  1593. *** precision increased to 15
  1594. {y=2.0,y=2.00000000000001}
  1595. %{y=2.0,y=2.00000000000001}
  1596. % 102) still higher precision needed.
  1597. zz:= (y-2)*(10000000000000000000y-20000000000000000001);
  1598. 2
  1599. zz := 10000000000000000000*y - 40000000000000000001*y + 40000000000000000002
  1600. roots zz;
  1601. *** precision increased to 20
  1602. {y=2.0,y=2.0000000000000000001}
  1603. %{y=2.0,y=2.0000000000000000001}
  1604. % 103) increase in precision required for substituted polynomial.
  1605. zz:= (x-2)*(10000000000x-20000000001);
  1606. 4 2
  1607. zz := 10000000000*y - 40000000001*y + 40000000002
  1608. roots zz;
  1609. {y= - 1.41421356237,
  1610. y=1.41421356237,
  1611. y= - 1.41421356241,
  1612. y=1.41421356241}
  1613. %{y= - 1.41421356237,y=1.41421356237,y= - 1.41421356241,y=1.41421356241}
  1614. % 104) still higher precision required for substituted polynomial.
  1615. zz:= (x-2)*(100000000000000x-200000000000001);
  1616. 4 2
  1617. zz := 100000000000000*y - 400000000000001*y + 400000000000002
  1618. roots zz;
  1619. *** input of these values may require precision >= 16
  1620. {y= - 1.414213562373095,
  1621. y=1.414213562373095,
  1622. y= - 1.414213562373099,
  1623. y=1.414213562373099}
  1624. %{y= - 1.414213562373095,y=1.414213562373095,
  1625. % y= - 1.414213562373099,y=1.414213562373099}
  1626. % 105) accuracy must be increased to separate root of complex factor
  1627. % from root of real factor.
  1628. zz:=(9y-10)*(y-2)*(9y-10-9i/100000000);
  1629. 3 2
  1630. zz := (8100000000*y - (34200000000 + 81*i)*y + (46000000000 + 252*i)*y
  1631. - (20000000000 + 180*i))/100000000
  1632. roots zz;
  1633. {y=1.111111111,y=2.0,y=1.111111111 + 0.00000001*i}
  1634. %{y=1.111111111,y=2.0,y=1.111111111 + 0.00000001*i}
  1635. % 106) realroots does the same accuracy increase for real root based
  1636. % upon the presence of a close complex root in the same polynomial.
  1637. % The reason for this might not be obvious unless roots is called.
  1638. realroots zz;
  1639. {y=1.111111111,y=2.0}
  1640. %{y=1.111111111,y=2.0}
  1641. % 107) realroots now uses powergcd logic whenever it is applicable.
  1642. zz := (x-1)*(x-2)*(x-3);
  1643. 6 4 2
  1644. zz := y - 6*y + 11*y - 6
  1645. realroots zz;
  1646. {y= - 1,
  1647. y=1,
  1648. y= - 1.41421,
  1649. y=1.41421,
  1650. y= - 1.73205,
  1651. y=1.73205}
  1652. %{y= - 1,y=1,y= - 1.41421,y=1.41421,y= - 1.73205,y=1.73205}
  1653. realroots(zz,exclude 1,2);
  1654. {y=1.41421,y=1.73205}
  1655. %{y=1.41421,y=1.73205}
  1656. % 108) root of degree 1 polynomial factor must be evaluated at
  1657. % precision 18 and accuracy 10 in order to separate it from a root of
  1658. % another real factor.
  1659. clear x;
  1660. zz:=(9x-10)**2*(9x-10-9/100000000)*(x-2);
  1661. 4 3 2
  1662. zz := (72900000000*x - 388800000729*x + 756000003078*x - 640000004140*x
  1663. + 200000001800)/100000000
  1664. roots zz;
  1665. {x=1.111111111,
  1666. x=1.111111111,
  1667. x=1.111111121,
  1668. x=2.0}
  1669. %{x=1.111111111,x=1.111111111,x=1.111111121,x=2.0}
  1670. nearestroot(zz,1);
  1671. {x=1.111111111}
  1672. %{x=1.111111111}
  1673. nearestroot(zz,1.5);
  1674. {x=1.111111121}
  1675. %{x=1.111111121}
  1676. nearestroot(zz,1.65);
  1677. {x=2.0}
  1678. %{x=2.0}
  1679. % 108a) new cability in mod 1.94.
  1680. realroots zz;
  1681. {x=1.111111111,
  1682. x=1.111111111,
  1683. x=1.111111121,
  1684. x=2.0}
  1685. %{x=1.111111111,x=1.111111111,x=1.111111121,x=2.0}
  1686. % 109) in this example, precision >=40 is used and two roots need to be
  1687. % found to accuracy 16 and two to accuracy 14.
  1688. zz := (9x-10)*(7x-8)*(9x-10-9/10**12)*(7x-8-7/10**14);
  1689. 4 3
  1690. zz := (396900000000000000000000000000*x - 1789200000000400869000000000000*x
  1691. 2
  1692. + 3024400000001361556000000003969*x - 2272000000001541380000000008946*x
  1693. + 640000000000581600000000005040)/100000000000000000000000000
  1694. roots zz;
  1695. *** input of these values may require precision >= 16
  1696. {x=1.1111111111111,
  1697. x=1.1111111111121,
  1698. x=1.142857142857143,
  1699. x=1.142857142857153}
  1700. %{x=1.1111111111111,x=1.1111111111121,
  1701. % x=1.142857142857143,x=1.142857142857153}
  1702. % 110) very small real or imaginary parts of roots require high
  1703. % precision or exact computations, or they will be lost or incorrectly
  1704. % found.
  1705. zz := 1000000*r**18 + 250000000000*r**4 - 1000000*r**2 + 1;
  1706. 18 4 2
  1707. zz := 1000000*r + 250000000000*r - 1000000*r + 1
  1708. roots zz;
  1709. {r=2.42978*i,
  1710. r= - 2.42978*i,
  1711. r= - 1.05424 - 2.18916*i,
  1712. r=1.05424 + 2.18916*i,
  1713. r= - 1.05424 + 2.18916*i,
  1714. r=1.05424 - 2.18916*i,
  1715. r= - 0.00141421 - 1.6e-26*i,
  1716. r=0.00141421 + 1.6e-26*i,
  1717. r= - 0.00141421 + 1.6e-26*i,
  1718. r=0.00141421 - 1.6e-26*i,
  1719. r= - 1.89968 - 1.51494*i,
  1720. r=1.89968 + 1.51494*i,
  1721. r= - 1.89968 + 1.51494*i,
  1722. r=1.89968 - 1.51494*i,
  1723. r= - 2.36886 - 0.540677*i,
  1724. r=2.36886 + 0.540677*i,
  1725. r= - 2.36886 + 0.540677*i,
  1726. r=2.36886 - 0.540677*i}
  1727. %{r=2.42978*i,r=-2.42978*i,
  1728. % r=-1.05424 - 2.18916*i,r=1.05424 + 2.18916*i,
  1729. % r=-1.05424 + 2.18916*i,r=1.05424 - 2.18916*i,
  1730. % r=-0.00141421 - 1.6E-26*i,r=0.00141421 + 1.6E-26*i,
  1731. % r=-0.00141421 + 1.6E-26*i,r=0.00141421 - 1.6E-26*i,
  1732. % r=-1.89968 - 1.51494*i,r=1.89968 + 1.51494*i,
  1733. % r=-1.89968 + 1.51494*i,r=1.89968 - 1.51494*i,
  1734. % r=-2.36886 - 0.540677*i,r=2.36886 + 0.540677*i,
  1735. % r=-2.36886 + 0.540677*i,r=2.36886 - 0.540677*i}
  1736. comment These five examples are very difficult root finding problems
  1737. for automatic root finding (not employing problem-specific
  1738. procedures.) They require extremely high precision and high accuracy
  1739. to separate almost multiple roots (multiplicity broken by a small high
  1740. order perturbation.) The examples are roughly in ascending order of
  1741. difficulty.;
  1742. % 111) Two simple complex roots with extremely small real separation.
  1743. c := 10^-6;
  1744. 1
  1745. c := ---------
  1746. 1000000
  1747. zz:=(x-3c^2)^2+i*c*x^7;
  1748. zz :=
  1749. 7 2
  1750. 1000000000000000000*i*x + 1000000000000000000000000*x - 6000000000000*x + 9
  1751. -------------------------------------------------------------------------------
  1752. 1000000000000000000000000
  1753. roots zz;
  1754. *** precision increased to 33
  1755. {x= - 15.0732 + 4.89759*i,
  1756. x= - 9.31577 - 12.8221*i,
  1757. x= - 1.2e-12 + 15.8489*i,
  1758. x=2.99999999999999999999999999999997e-12
  1759. + 3.3068111527572904325663335008527e-44*i,
  1760. x=3.00000000000000000000000000000003e-12
  1761. - 3.30681115275729043256633350085321e-44*i,
  1762. x=9.31577 - 12.8221*i,
  1763. x=15.0732 + 4.89759*i}
  1764. %{x=-15.0732 + 4.89759*i,x=-9.31577 - 12.8221*i,x=-1.2E-12 + 15.8489*i,
  1765. % x=2.99999999999999999999999999999997E-12
  1766. % + 3.3068111527572904325663335008527E-44*i,
  1767. % x=3.00000000000000000000000000000003E-12
  1768. % - 3.30681115275729043256633350085321E-44*i,
  1769. % x=9.31577 - 12.8221*i,x=15.0732 + 4.89759*i}
  1770. % 112) Four simple complex roots in two close sets.
  1771. c := 10^-4;
  1772. 1
  1773. c := -------
  1774. 10000
  1775. zz:=(x^2-3c^2)^2+i*c^2*x^9;
  1776. 9 4 2
  1777. 100000000*i*x + 10000000000000000*x - 600000000*x + 9
  1778. zz := ----------------------------------------------------------
  1779. 10000000000000000
  1780. roots zz;
  1781. *** input of these values may require precision >= 15
  1782. {x= - 37.8622 + 12.3022*i,
  1783. x= - 23.4002 - 32.2075*i,
  1784. x= - 0.00017320508075689 - 2.41778234660324e-18*i,
  1785. x= - 0.000173205080756885 + 2.4177823466027e-18*i,
  1786. x=39.8107*i,
  1787. x=0.000173205080756885 + 2.4177823466027e-18*i,
  1788. x=0.00017320508075689 - 2.41778234660324e-18*i,
  1789. x=23.4002 - 32.2075*i,
  1790. x=37.8622 + 12.3022*i}
  1791. %{x=-37.8622 + 12.3022*i,x=-23.4002 - 32.2075*i,
  1792. % x=-0.00017320508075689 - 2.41778234660324E-18*i,
  1793. % x=-0.000173205080756885 + 2.4177823466027E-18*i,
  1794. % x=39.8107*i,
  1795. % x=0.000173205080756885 + 2.4177823466027E-18*i,
  1796. % x=0.00017320508075689 - 2.41778234660324E-18*i,
  1797. % x=23.4002 - 32.2075*i,x=37.8622 + 12.3022*i}
  1798. % 113) Same example, but with higher minimum root accuracy specified.
  1799. rootacc 20;
  1800. 20
  1801. roots zz;
  1802. {x= - 37.862241873586290526 + 12.302188128448775345*i,
  1803. x= - 23.400152368145827118 - 32.207546656274351069*i,
  1804. x= - 0.00017320508075689014714 - 2.417782346603239319e-18*i,
  1805. x= - 0.00017320508075688531157 + 2.417782346602699319e-18*i,
  1806. x=39.810717055651151449*i,
  1807. x=0.00017320508075688531157 + 2.417782346602699319e-18*i,
  1808. x=0.00017320508075689014714 - 2.417782346603239319e-18*i,
  1809. x=23.400152368145827118 - 32.207546656274351069*i,
  1810. x=37.862241873586290526 + 12.302188128448775345*i}
  1811. %{x=-37.862241873586290526 + 12.302188128448775345*i,
  1812. % x=-23.400152368145827118 - 32.207546656274351069*i,
  1813. % x=-0.00017320508075689014714 - 2.417782346603239319E-18*i,
  1814. % x=-0.00017320508075688531157 + 2.417782346602699319E-18*i,
  1815. % x=39.810717055651151449*i,
  1816. % x=0.00017320508075688531157 + 2.417782346602699319E-18*i,
  1817. % x=0.00017320508075689014714 - 2.417782346603239319E-18*i,
  1818. % x=23.400152368145827118 - 32.207546656274351069*i,
  1819. % x=37.862241873586290526 + 12.302188128448775345*i}
  1820. precision reset;
  1821. 33
  1822. % This resets precision and rootacc to nominal.
  1823. % 114) Two extremely close real roots plus a complex pair with extremely
  1824. % small imaginary part.
  1825. c := 10^6;
  1826. c := 1000000
  1827. zz:=(c^2*x^2-3)^2+c^2*x^9;
  1828. 9 4 2
  1829. zz := 1000000000000*x + 1000000000000000000000000*x - 6000000000000*x + 9
  1830. roots zz;
  1831. *** precision increased to 22
  1832. {x= - 251.189,
  1833. x= - 77.6216 + 238.895*i,
  1834. x= - 77.6216 - 238.895*i,
  1835. x= - 0.000001732050807568877293531,
  1836. x= - 0.000001732050807568877293524,
  1837. x=0.00000173205 + 3.41926e-27*i,
  1838. x=0.00000173205 - 3.41926e-27*i,
  1839. x=203.216 + 147.645*i,
  1840. x=203.216 - 147.645*i}
  1841. %{x= - 251.189,x=-77.6216 + 238.895*i,x=-77.6216 - 238.895*i,
  1842. % x= - 0.000001732050807568877293531,
  1843. % x= - 0.000001732050807568877293524,
  1844. % x=0.00000173205 + 3.41926E-27*i,x=0.00000173205 - 3.41926E-27*i,
  1845. % x=203.216 + 147.645*i,x=203.216 - 147.645*i}
  1846. % 114a) this example is a critical test for realroots as well.
  1847. realroots zz;
  1848. {x= - 251.189,x= - 0.000001732050807568877293531,x
  1849. = - 0.000001732050807568877293524}
  1850. %{x= - 251.189,x= - 0.000001732050807568877293531,
  1851. % x= - 0.000001732050807568877293524}
  1852. % 115) Four simple complex roots in two extremely close sets.
  1853. c := 10^6;
  1854. c := 1000000
  1855. zz:=(c^2*x^2-3)^2+i*c^2*x^9;
  1856. 9 4 2
  1857. zz := 1000000000000*i*x + 1000000000000000000000000*x - 6000000000000*x + 9
  1858. roots zz;
  1859. {x= - 238.895 + 77.6216*i,
  1860. x= - 147.645 - 203.216*i,
  1861. x= - 0.00000173205080756887729353 - 2.417782346602969319022e-27*i,
  1862. x= - 0.000001732050807568877293525 + 2.417782346602969318968e-27*i,
  1863. x=251.189*i,
  1864. x=0.000001732050807568877293525 + 2.417782346602969318968e-27*i,
  1865. x=0.00000173205080756887729353 - 2.417782346602969319022e-27*i,
  1866. x=147.645 - 203.216*i,
  1867. x=238.895 + 77.6216*i}
  1868. %{x=-238.895 + 77.6216*i,x=-147.645 - 203.216*i,
  1869. % x=-0.00000173205080756887729353 - 2.417782346602969319022E-27*i,
  1870. % x=-0.000001732050807568877293525 + 2.417782346602969318968E-27*i,
  1871. % x=251.189*i,
  1872. % x=0.000001732050807568877293525 + 2.417782346602969318968E-27*i,
  1873. % x=0.00000173205080756887729353 - 2.417782346602969319022E-27*i,
  1874. % x=147.645 - 203.216*i,x=238.895 + 77.6216*i}
  1875. % 116) A new "hardest example" type. This polynomial has two sets of
  1876. % extremely close real roots and two sets of extremely close conjugate
  1877. % complex roots, both large and small, with the maximum accuracy and
  1878. % precision required for the largest roots. Three restarts are
  1879. % required, at progressively higher precision, to find all roots.
  1880. % (to run this example, uncomment the following two lines.)
  1881. %**% zz1:= (10^12x^2-sqrt 2)^2+x^7$ zz2:= (10^12x^2+sqrt 2)^2+x^7$
  1882. %**% zzzz := zz1*zz2$ roots zzzz;
  1883. %{x= - 1.00000000000000000000000000009E+8,
  1884. % x= - 9.99999999999999999999999999906E+7,
  1885. % x= - 0.0000011892071150027210667183,
  1886. % x= - 0.0000011892071150027210667167,
  1887. % x=-5.4525386633262882960501E-28 + 0.000001189207115002721066718*i,
  1888. % x=-5.4525386633262882960501E-28 - 0.000001189207115002721066718*i,
  1889. % x=5.4525386633262882960201E-28 + 0.000001189207115002721066717*i,
  1890. % x=5.4525386633262882960201E-28 - 0.000001189207115002721066717*i,
  1891. % x=0.00000118921 + 7.71105E-28*i,
  1892. % x=0.00000118921 - 7.71105E-28*i,
  1893. % x=4.99999999999999999999999999953E+7
  1894. % + 8.66025403784438646763723170835E+7*i,
  1895. % x=4.99999999999999999999999999953E+7
  1896. % - 8.66025403784438646763723170835E+7*i,
  1897. % x=5.00000000000000000000000000047E+7
  1898. % + 8.66025403784438646763723170671E+7*i,
  1899. % x=5.00000000000000000000000000047E+7
  1900. % - 8.66025403784438646763723170671E+7*i}
  1901. % Realroots strategy on this example is different, but determining the
  1902. % necessary precision and accuracy is tricky.
  1903. %**% realroots zzzz;
  1904. %{x= - 1.00000000000000000000000000009E+8,
  1905. % x= - 9.9999999999999999999999999991E+7,
  1906. % x= - 0.0000011892071150027210667183,
  1907. % x= - 0.0000011892071150027210667167}
  1908. % 117) multroot examples. Multroot can be called directly, or it can be
  1909. % called by giving roots or realroots a list of polynomials as argument.
  1910. % Here, multroot is called directly. Realroots is used unless the switch
  1911. % compxroots is on. In this example, p1 must be computed at accuracy 33
  1912. % in order to yield an accuracy of 20 for p2.
  1913. res := % Structure is {eq1(p1,p2),eq2(p1)}
  1914. { - 65193331905902035840886401184447471772856493442267717*P1**13
  1915. - 1664429561324832520726401259146912155464247056480012434*P1**12
  1916. - 6261475374084274810766056740641579522309310708502887990*P1**11
  1917. + 58050875148721867394302891225676265051604299348469583622*P1**10
  1918. - 25149162547648105419319267662238682603649922079217227285*P1**9
  1919. - 440495842372965561251919788209759089436362766115660350108*P1**8
  1920. + 1031835865631194068430476093579502290454870220388968336688*P1**7
  1921. - 176560168441303582471783015188457142709772508915411137856*P1**6
  1922. - 3394297397883799767380936436924078166849454318674637153232*P1**5
  1923. + 8572159983028240622274769676964404195355003175115163884096*P1**4
  1924. - 11689989317682872105592244166702248132836279639925035950656*P1**3
  1925. + 9646776768609439752430866001814626337809195004192011294976*P1**2
  1926. - 4455646388442119339178004445898515058096390082146233345536*P1
  1927. + 4709370575236909034773453200518274143851133066819671040*P2
  1928. + 886058257542744466307567014351806947093655767531394713600,
  1929. 53271*P1**14 + 1393662*P1**13 + 6077030*P1**12 - 41382626*P1**11
  1930. + 6240255*P1**10 + 313751524*P1**9 - 698694844*P1**8
  1931. + 134987928*P1**7 + 2322386256*P1**6 - 6102636608*P1**5
  1932. + 8722164608*P1**4 - 7907887488*P1**3 + 4508378368*P1**2
  1933. - 1477342720*P1 + 213248000}$
  1934. multroot(20,res);
  1935. {{p1= - 16.330244199212269912,p2= - 12.905402440394357204},{p1
  1936. = - 13.071850241794867852,p2= - 20.369934278813005573}}
  1937. %{{p1= - 16.330244199212269912,p2= - 12.905402440394357204},{p1
  1938. % = - 13.071850241794867852,p2= - 20.369934278813005573}}
  1939. % 118) structure is {p1(x1,x3,x4),p2(x2,x4),p3(x2,x3,x4),p4(x4)}
  1940. h := {36439926476029643745*x1 + 36439926476029643745*x3
  1941. - 966689910765785535050240000*x4**17
  1942. + 2589213991952971388822784000*x4**16
  1943. - 1455736281904024746728256000*x4**15
  1944. - 1114734065976529083327407360*x4**14
  1945. + 720240539282202478990426752*x4**13
  1946. + 419779761544955697624679296*x4**12
  1947. - 168749980172837712266699840*x4**11
  1948. + 290913179471491189688854560*x4**10 - 432958804125555395247740688*x4**9
  1949. + 10386593827154614897599504*x4**8 + 155547361883654478618679440*x4**7
  1950. - 31113996003728470659075480*x4**6 - 41175755320900503555096780*x4**5
  1951. + 33003268068791208924709740*x4**4 - 6778828915691466390091200*x4**3
  1952. - 1496167017611703417373950*x4**2 + 149688116448660711183825*x4
  1953. + 138148004064999041884935,
  1954. - 36439926476029643745*x2 - 784034192593211415232000000*x4**17
  1955. + 2099814921874128508369920000*x4**16
  1956. - 1180307545285783973854272000*x4**15
  1957. - 904159020650675303719168000*x4**14
  1958. + 583907514538684395627559680*x4**13
  1959. + 340458856280381353403249664*x4**12
  1960. - 136785894094420325707236352*x4**11
  1961. + 235962131906791901454310848*x4**10
  1962. - 351090033711917923140908256*x4**9 + 8379974606095284871931520*x4**8
  1963. + 126131069262992237456374584*x4**7 -25220359028157888406315896*x4**6
  1964. - 33393008746801847984243640*x4**5 + 26761347051713933045852160*x4**4
  1965. - 5495296446381334401240210*x4**3 - 1213098761225775782417310*x4**2
  1966. + 121243165959568584810870*x4 + 112046752277725240396125,
  1967. 145759705904118574980*x3**2 - 3866759643063142140200960000*x3*x4**17
  1968. + 10356855967811885555291136000*x3*x4**16
  1969. - 5822945127616098986913024000*x3*x4**15
  1970. - 4458936263906116333309629440*x3*x4**14
  1971. + 2880962157128809915961707008*x3*x4**13
  1972. + 1679119046179822790498717184*x3*x4**12
  1973. - 674999920691350849066799360*x3*x4**11
  1974. + 1163652717885964758755418240*x3*x4**10
  1975. - 1731835216502221580990962752*x3*x4**9
  1976. + 41546375308618459590398016*x3*x4**8
  1977. + 622189447534617914474717760*x3*x4**7
  1978. - 124455984014913882636301920*x3*x4**6
  1979. - 164703021283602014220387120*x3*x4**5
  1980. + 132013072275164835698838960*x3*x4**4
  1981. - 27115315662765865560364800*x3*x4**3
  1982. - 5984668070446813669495800*x3*x4**2 + 598752465794642844735300*x3*x4
  1983. + 552592016259996167539740*x3 + 3550270013715070172487680000*x4**17
  1984. - 9573649159583488469933568000*x4**16
  1985. + 5464438450196473162575360000*x4**15
  1986. + 4096921924516221821604523520*x4**14
  1987. - 2717026023466705910519606784*x4**13
  1988. - 1554544907157405816469959168*x4**12
  1989. + 636859360057972319632500992*x4**11
  1990. - 1065163663567422851531986944*x4**10
  1991. + 1612243029585251439302638656*x4**9
  1992. - 48252032958282805311135168*x4**8 - 579133322758350220074700320*x4**7
  1993. + 117976179842506552019678280*x4**6 + 152287445048713077301910400*x4**5
  1994. - 123053170142513516618082960*x4**4 + 25533441675517563881962200*x4**3
  1995. + 5583415080801636858130200*x4**2 - 574247940288215661001800*x4
  1996. - 518304795930023609925945,
  1997. - 5120000*x4**18 + 18432000*x4**17 - 20352000*x4**16 + 1208320*x4**15
  1998. + 9255936*x4**14 - 1296384*x4**13 - 2943488*x4**12 + 2365440*x4**11
  1999. - 3712896*x4**10 + 2169600*x4**9 + 772560*x4**8 - 924480*x4**7
  2000. - 66000*x4**6 + 375840*x4**5 - 197100*x4**4 + 25200*x4**3 + 8100*x4**2
  2001. - 675}$
  2002. multroot(20,h);
  2003. {{x1= - 0.12444800707566022364,x2=0.40264591905223704246,x3
  2004. =0.70281784593572688134,x4=0.92049796029182926078},
  2005. {x1= - 0.12444800707566022364,x2=0.92049796029182926078,x3
  2006. =0.70281784593572688134,x4=0.40264591905223704246},
  2007. {x1=0.22075230018295426413,x2=0.48100256896929398759,x3=0.74057635603986743051,
  2008. x4=0.93049526909398804249},
  2009. {x1=0.22075230018295426413,x2=0.93049526909398804249,x3=0.74057635603986743051,
  2010. x4=0.48100256896929398759},
  2011. {x1=0.70281784593572688134,x2=0.40264591905223704246,x3
  2012. = - 0.12444800707566022364,x4=0.92049796029182926078},
  2013. {x1=0.70281784593572688134,x2=0.92049796029182926078,x3
  2014. = - 0.12444800707566022364,x4=0.40264591905223704246},
  2015. {x1=0.74057635603986743051,x2=0.48100256896929398759,x3=0.22075230018295426413,
  2016. x4=0.93049526909398804249},
  2017. {x1=0.74057635603986743051,x2=0.93049526909398804249,x3=0.22075230018295426413,
  2018. x4=0.48100256896929398759}}
  2019. %{{x1= - 0.12444800707566022364,x2=0.40264591905223704246,x3
  2020. % =0.70281784593572688134,x4=0.92049796029182926078},
  2021. % {x1= - 0.12444800707566022364,x2=0.92049796029182926078,x3
  2022. % =0.70281784593572688134,x4=0.40264591905223704246},
  2023. % {x1=0.22075230018295426413,x2=0.48100256896929398759,x3
  2024. % =0.74057635603986743051,x4=0.93049526909398804249},
  2025. % {x1=0.22075230018295426413,x2=0.93049526909398804249,x3
  2026. % =0.74057635603986743051,x4=0.48100256896929398759},
  2027. % {x1=0.70281784593572688134,x2=0.40264591905223704246,x3
  2028. % = - 0.12444800707566022364,x4=0.92049796029182926078},
  2029. % {x1=0.70281784593572688134,x2=0.92049796029182926078,x3
  2030. % = - 0.12444800707566022364,x4=0.40264591905223704246},
  2031. % {x1=0.74057635603986743051,x2=0.48100256896929398759,x3
  2032. % =0.22075230018295426413,x4=0.93049526909398804249},
  2033. % {x1=0.74057635603986743051,x2=0.93049526909398804249,x3
  2034. % =0.22075230018295426413,x4=0.48100256896929398759}}
  2035. % System precision will have been set to 20 in the two previous
  2036. % examples. In the following examples, the roots will be given to
  2037. % accuracy 12, because rootacc 12; was input. If rootacc had not been
  2038. % input, the roots would be given at system precision, which could
  2039. % different answers on different systems if precision had been reset,
  2040. % or else it would have been 20 because of example 118).
  2041. rootacc 12;
  2042. 12
  2043. % 119)
  2044. ss := {x^2-2,y^2-x^2,z^2-x-y};
  2045. 2 2 2 2
  2046. ss := {x - 2, - x + y , - x - y + z }
  2047. % structure is {p1(x),p2(x,y),p3(x,y,z)}
  2048. realroots ss;
  2049. {{x= - 1.41421356237,y=1.41421356237,z=0},
  2050. {x= - 1.41421356237,y=1.41421356237,z=0},
  2051. {x=1.41421356237,y= - 1.41421356237,z=0},
  2052. {x=1.41421356237,y= - 1.41421356237,z=0},
  2053. {x=1.41421356237,y=1.41421356237,z= - 1.68179283051},
  2054. {x=1.41421356237,y=1.41421356237,z=1.68179283051}}
  2055. %{{x= - 1.41421356237,y=1.41421356237,z=0},
  2056. % {x= - 1.41421356237,y=1.41421356237,z=0},
  2057. % {x=1.41421356237,y= - 1.41421356237,z=0},
  2058. % {x=1.41421356237,y= - 1.41421356237,z=0},
  2059. % {x=1.41421356237,y=1.41421356237,z= - 1.68179283051},
  2060. % {x=1.41421356237,y=1.41421356237,z=1.68179283051}}
  2061. roots ss;
  2062. {{x= - 1.41421356237,y= - 1.41421356237,z=1.68179283051*i},
  2063. {x= - 1.41421356237,y= - 1.41421356237,z= - 1.68179283051*i},
  2064. {x= - 1.41421356237,y=1.41421356237,z=0},
  2065. {x= - 1.41421356237,y=1.41421356237,z=0},
  2066. {x=1.41421356237,y= - 1.41421356237,z=0},
  2067. {x=1.41421356237,y= - 1.41421356237,z=0},
  2068. {x=1.41421356237,y=1.41421356237,z= - 1.68179283051},
  2069. {x=1.41421356237,y=1.41421356237,z=1.68179283051}}
  2070. %{{x= - 1.41421356237,y= - 1.41421356237,z=1.68179283051*i},
  2071. % {x= - 1.41421356237,y= - 1.41421356237,z= - 1.68179283051*i},
  2072. % {x= - 1.41421356237,y=1.41421356237,z=0},
  2073. % {x= - 1.41421356237,y=1.41421356237,z=0},
  2074. % {x=1.41421356237,y= - 1.41421356237,z=0},
  2075. % {x=1.41421356237,y= - 1.41421356237,z=0},
  2076. % {x=1.41421356237,y=1.41421356237,z= - 1.68179283051},
  2077. % {x=1.41421356237,y=1.41421356237,z=1.68179283051}}
  2078. % 120)
  2079. realroots {x^5-45x+2,y^2-x+1};
  2080. {{x=2.57878769906,y= - 1.25649818904},{x=2.57878769906,y=1.25649818904}}
  2081. %{{x=2.57878769906,y= - 1.25649818904},{x=2.57878769906,y
  2082. % =1.25649818904}}
  2083. realroots {x^5-45x+2,y^2-x-1};
  2084. {{x=0.0444444482981,y= - 1.02198064967},
  2085. {x=0.0444444482981,y=1.02198064967},
  2086. {x=2.57878769906,y= - 1.89176840524},
  2087. {x=2.57878769906,y=1.89176840524}}
  2088. %{{x=0.0444444482981,y= - 1.02198064967},
  2089. % {x=0.0444444482981,y=1.02198064967},
  2090. % {x=2.57878769906,y= - 1.89176840524},
  2091. % {x=2.57878769906,y=1.89176840524}}
  2092. % 121)
  2093. realroots {x^2-2,y^2+x^2};
  2094. {}
  2095. % {}
  2096. roots {x^2+2,y^2-x^2};
  2097. {{x=1.41421356237*i,y=1.41421356237*i},
  2098. {x=1.41421356237*i,y= - 1.41421356237*i},
  2099. {x= - 1.41421356237*i,y=1.41421356237*i},
  2100. {x= - 1.41421356237*i,y= - 1.41421356237*i}}
  2101. %{{x=1.41421356237*i,y=1.41421356237*i},
  2102. % {x=1.41421356237*i,y= - 1.41421356237*i},
  2103. % {x= - 1.41421356237*i,y=1.41421356237*i},
  2104. % {x= - 1.41421356237*i,y= - 1.41421356237*i}}
  2105. % 122)
  2106. roots {x^2-y^2,x^2+y^2+3};
  2107. *** multroot fails because no univariate polynomial was given.
  2108. 2 2 2 2
  2109. multroot(12,{x - y ,x + y + 3})
  2110. %multroot fails because no univariate polynomial was given.
  2111. %multroot(12,{x**2 - y**2,x**2 + y**2 + 3})$
  2112. % 122a)
  2113. roots{x^2+y^2,x^2-y^2-z,z^2-z-1};
  2114. *** multroot failure: at least one polynomial has no single base.
  2115. 2 2 2 2 2
  2116. multroot(12,{x + y ,x - y - z,z - z - 1})
  2117. %*** multroot failure: at least one polynomial has no single base.
  2118. %multroot(12,{x**2 + y**2,(x**2 - y**2) - z,(z**2 - z) - 1})$
  2119. % 123)
  2120. roots {x^2-2,y^2+3,x+z-2,y-z+2};
  2121. {}
  2122. %{}
  2123. % 124)
  2124. zz := {x^5-5x+3,x^2+y^2,x^3+z^3};
  2125. 5 2 2 3 3
  2126. zz := {x - 5*x + 3,x + y ,x + z }
  2127. realroots zz;
  2128. {}
  2129. %{}
  2130. realroots {x^5-5x+3,x^2-y^2,x^3+z^3};
  2131. {{x= - 1.61803398875,y= - 1.61803398875,z=1.61803398875},
  2132. {x= - 1.61803398875,y=1.61803398875,z=1.61803398875},
  2133. {x=0.61803398875,y= - 0.61803398875,z= - 0.61803398875},
  2134. {x=0.61803398875,y=0.61803398875,z= - 0.61803398875},
  2135. {x=1.27568220365,y= - 1.27568220365,z= - 1.27568220365},
  2136. {x=1.27568220365,y=1.27568220365,z= - 1.27568220365}}
  2137. %{{x= - 1.61803398875,y= - 1.61803398875,z=1.61803398875},
  2138. % {x= - 1.61803398875,y=1.61803398875,z=1.61803398875},
  2139. % {x=0.61803398875,y= - 0.61803398875,z= - 0.61803398875},
  2140. % {x=0.61803398875,y=0.61803398875,z= - 0.61803398875},
  2141. % {x=1.27568220365,y= - 1.27568220365,z= - 1.27568220365},
  2142. % {x=1.27568220365,y=1.27568220365,z= - 1.27568220365}}
  2143. % These show previous capability
  2144. %------------------------------------------------------------------
  2145. % These are new capability
  2146. % 125)
  2147. roots{x**2 - x - y,x*y - 2*y,y**2 - 2*y};
  2148. {{x=0,y=0},{x=1,y=0},{x=2.0,y=2.0}}
  2149. %{{x=0,y=0},{x=1,y=0},{x=2.0,y=2.0}}
  2150. % 126)
  2151. roots({x^2-9,y^3-27,x*y+9});
  2152. {{x= - 3.0,y=3.0}}
  2153. %{{x= - 3.0,y=3.0}}
  2154. % 127)
  2155. multroot(12,{y^2-z,y*z,z*(z-1)});
  2156. {{y=0,z=0},{y=0,z=0}}
  2157. %{{y=0,z=0},{y=0,z=0}}
  2158. % 127a)
  2159. multroot(12,{y^2-z,y*z,z*(z-1),x^2-x-y});
  2160. {{x=0,y=0,z=0},
  2161. {x=0,y=0,z=0},
  2162. {x=1,y=0,z=0},
  2163. {x=1,y=0,z=0}}
  2164. %{{x=0,y=0,z=0},
  2165. % {x=0,y=0,z=0},
  2166. % {x=1,y=0,z=0},
  2167. % {x=1,y=0,z=0}}
  2168. % 128)
  2169. roots{y*z,z*(z-1)};
  2170. {{z=0},{y=0,z=1}}
  2171. %{{z=0},{y=0,z=1}}
  2172. % 129)
  2173. zzl := {z*(z-1)*(z-2),(z-2)*z*y^2+(z-1)*z*y+z+1};
  2174. 2
  2175. zzl := {z*(z - 3*z + 2),
  2176. 2 2 2 2
  2177. y *z - 2*y *z + y*z - y*z + z + 1}
  2178. roots zzl;
  2179. {{y= - 1.5,z=2.0},{y= - 1.41421356237,z=1},{y=1.41421356237,z=1}}
  2180. %{{y= - 1.5,z=2.0},
  2181. % {y= - 1.41421356237,z=1},
  2182. % {y=1.41421356237,z=1}}
  2183. % 129a)
  2184. zzla := {z*(z-1)*(z-2),(z-2)*z*y^2+(z-1)*z*y+z+1,x^2-x-y};
  2185. 2
  2186. zzla := {z*(z - 3*z + 2),
  2187. 2 2 2 2
  2188. y *z - 2*y *z + y*z - y*z + z + 1,
  2189. 2
  2190. x - x - y}
  2191. roots zzla;
  2192. {{x= - 0.790044015673,y=1.41421356237,z=1},
  2193. {x=0.5 + 1.11803398875*i,y= - 1.5,z=2.0},
  2194. {x=0.5 - 1.11803398875*i,y= - 1.5,z=2.0},
  2195. {x=0.5 + 1.07898728555*i,y= - 1.41421356237,z=1},
  2196. {x=0.5 - 1.07898728555*i,y= - 1.41421356237,z=1},
  2197. {x=1.79004401567,y=1.41421356237,z=1}}
  2198. %{{x= - 0.790044015673,y=1.41421356237,z=1},
  2199. % {x=0.5 + 1.11803398875*i,y= - 1.5,z=2.0},
  2200. % {x=0.5 - 1.11803398875*i,y= - 1.5,z=2.0},
  2201. % {x=0.5 + 1.07898728555*i,y= - 1.41421356237,z=1},
  2202. % {x=0.5 - 1.07898728555*i,y= - 1.41421356237,z=1},
  2203. % {x=1.79004401567,y=1.41421356237,z=1}}
  2204. % 130)
  2205. zzl0 := {z*(z-1)*(z-2),(z-2)*z*y^2+(z-1)*z*y+z};
  2206. 2
  2207. zzl0 := {z*(z - 3*z + 2),
  2208. 2 2
  2209. z*(y *z - 2*y + y*z - y + 1)}
  2210. roots zzl0;
  2211. {{y=-1,z=1},{y=-1,z=2.0},{z=0},{y=1,z=1}}
  2212. %{{y=-1,z=1},{y=-1,z=2.0},{z=0},{y=1,z=1}}
  2213. % 131)
  2214. zzl3a := {z*(z-1)*(z-2),(z-2)*z*y^2+(z-1)*z*y+z,x^2+y*x*z+z};
  2215. 2
  2216. zzl3a := {z*(z - 3*z + 2),
  2217. 2 2
  2218. z*(y *z - 2*y + y*z - y + 1),
  2219. 2
  2220. x + x*y*z + z}
  2221. roots zzl3a;
  2222. {{x= - 0.5 + 0.866025403784*i,y=1,z=1},
  2223. {x= - 0.5 - 0.866025403784*i,y=1,z=1},
  2224. {x=0,z=0},
  2225. {x=0,z=0},
  2226. {x=0.5 + 0.866025403784*i,y=-1,z=1},
  2227. {x=0.5 - 0.866025403784*i,y=-1,z=1},
  2228. {x=1 + i,y=-1,z=2.0},
  2229. {x=1 - i,y=-1,z=2.0}}
  2230. %{{x=0.866025403784*i - 0.5,y=1,z=1},
  2231. % {x= - 0.866025403784*i - 0.5,y=1,z=1},
  2232. % {x=0,z=0},
  2233. % {x=0,z=0},
  2234. % {x=0.866025403784*i + 0.5,y=-1,z=1},
  2235. % {x= - 0.866025403784*i + 0.5,y=-1,z=1},
  2236. % {x=i + 1,y=-1,z=2.0},
  2237. % {x= - i + 1,y=-1,z=2.0}}$
  2238. % 132)
  2239. zzl3c := {z*(z-1)*(z-2),(z-2)*z*y^2+(z-1)*z*y+z,x^2+y*x+z};
  2240. 2
  2241. zzl3c := {z*(z - 3*z + 2),
  2242. 2 2
  2243. z*(y *z - 2*y + y*z - y + 1),
  2244. 2
  2245. x + x*y + z}
  2246. roots zzl3c;
  2247. *** for some root value(s), a variable depends on an arbitrary variable
  2248. 3 2
  2249. multroot(12,{z - 3*z + 2*z,
  2250. 2 2 2 2
  2251. y *z - 2*y *z + y*z - y*z + z,
  2252. 2
  2253. x + x*y + z})
  2254. %*** for some root value, a variable dependends on an arbitrary variable
  2255. %multroot(12,{z**3 - 3*z**2 + 2*z,y**2*z**2 - 2*y**2*z + y*z**2 - y*z + z,
  2256. % x**2 + x*y + z})$
  2257. % 133)
  2258. xyz := {x^2-x-2,y^2+y,x^3+y^3+z+5};
  2259. 2 3 3
  2260. xyz := {x - x - 2,y*(y + 1),x + y + z + 5}
  2261. roots xyz;
  2262. {{x=-1,y=-1,z= - 3.0},
  2263. {x=-1,y=0,z= - 4.0},
  2264. {x=2.0,y=-1,z= - 12.0},
  2265. {x=2.0,y=0,z= - 13.0}}
  2266. %{{x=-1,y=-1,z= - 3.0},
  2267. % {x=-1,y=0,z= - 4.0},
  2268. % {x=2.0,y=-1,z= - 12.0},
  2269. % {x=2.0,y=0,z= - 13.0}}
  2270. % 134) here, we had to eliminate a spurious imaginary part of z.
  2271. axyz := {a-1,a+x^2-x-2,a+y^2+y,a+x^3+y^3+z+5};
  2272. axyz := {a - 1,
  2273. 2
  2274. a + x - x - 2,
  2275. 2
  2276. a + y + y,
  2277. 3 3
  2278. a + x + y + z + 5}
  2279. roots axyz;
  2280. {{a=1,x= - 0.61803398875,y= - 0.5 + 0.866025403784*i,z= - 6.7639320225},
  2281. {a=1,x= - 0.61803398875,y= - 0.5 - 0.866025403784*i,z= - 6.7639320225},
  2282. {a=1,x=1.61803398875,y= - 0.5 + 0.866025403784*i,z= - 11.2360679775},
  2283. {a=1,x=1.61803398875,y= - 0.5 - 0.866025403784*i,z= - 11.2360679775}}
  2284. %{{a=1,x= - 0.61803398875,y= - 0.5 + 0.866025403784*i,z= - 6.7639320225},
  2285. % {a=1,x= - 0.61803398875,y= - 0.5 - 0.866025403784*i,z= - 6.7639320225},
  2286. % {a=1,x=1.61803398875,y= - 0.5 + 0.866025403784*i,z= - 11.2360679775},
  2287. % {a=1,x=1.61803398875,y= - 0.5 - 0.866025403784*i,z= - 11.2360679775}}
  2288. % 134a) here, we had to eliminate a spurious real part of x.
  2289. roots{y^4+y^3+y^2+y+1,x^2+3*y^5+2};
  2290. {{x=2.2360679775*i,y= - 0.809016994375 + 0.587785252292*i},
  2291. {x= - 2.2360679775*i,y= - 0.809016994375 + 0.587785252292*i},
  2292. {x= - 2.2360679775*i,y= - 0.809016994375 - 0.587785252292*i},
  2293. {x=2.2360679775*i,y= - 0.809016994375 - 0.587785252292*i},
  2294. {x= - 2.2360679775*i,y=0.309016994375 + 0.951056516295*i},
  2295. {x=2.2360679775*i,y=0.309016994375 + 0.951056516295*i},
  2296. {x=2.2360679775*i,y=0.309016994375 - 0.951056516295*i},
  2297. {x= - 2.2360679775*i,y=0.309016994375 - 0.951056516295*i}}
  2298. %{{x=2.2360679775*i,y= - 0.809016994375 + 0.587785252292*i},
  2299. % {x=-2.2360679775*i,y= - 0.809016994375 + 0.587785252292*i},
  2300. % {x=-2.2360679775*i,y= - 0.809016994375 - 0.587785252292*i},
  2301. % {x=2.2360679775*i,y= - 0.809016994375 - 0.587785252292*i},
  2302. % {x=-2.2360679775*i,y=0.309016994375 + 0.951056516295*i},
  2303. % {x=2.2360679775*i,y=0.309016994375 + 0.951056516295*i},
  2304. % {x=2.2360679775*i,y=0.309016994375 - 0.951056516295*i},
  2305. % {x=-2.2360679775*i,y=0.309016994375 - 0.951056516295*i}}
  2306. % 135)
  2307. axyz2 := {a-1,a-1+x^2-x-2,a-1+y^2+y,x^3+y^3+z+5};
  2308. axyz2 := {a - 1,
  2309. 2
  2310. a + x - x - 3,
  2311. 2
  2312. a + y + y - 1,
  2313. 3 3
  2314. x + y + z + 5}
  2315. roots axyz2;
  2316. {{a=1,x=-1,y=-1,z= - 3.0},
  2317. {a=1,x=-1,y=0,z= - 4.0},
  2318. {a=1,x=2.0,y=-1,z= - 12.0},
  2319. {a=1,x=2.0,y=0,z= - 13.0}}
  2320. %{{a=1,x=-1,y=-1,z= - 3.0},
  2321. % {a=1,x=-1,y=0,z= - 4.0},
  2322. % {a=1,x=2.0,y=-1,z= - 12.0},
  2323. % {a=1,x=2.0,y=0,z= - 13.0}}
  2324. zyxa2 := reverse axyz2;
  2325. 3 3
  2326. zyxa2 := {x + y + z + 5,
  2327. 2
  2328. a + y + y - 1,
  2329. 2
  2330. a + x - x - 3,
  2331. a - 1}
  2332. roots zyxa2;
  2333. {{a=1,x=-1,y=-1,z= - 3.0},
  2334. {a=1,x=-1,y=0,z= - 4.0},
  2335. {a=1,x=2.0,y=-1,z= - 12.0},
  2336. {a=1,x=2.0,y=0,z= - 13.0}}
  2337. % (same as above)
  2338. % 137)
  2339. rsxuv := {u^2+u*r+s*x*v,s+r^2,x-r-2,r+v,v^2-v-6};
  2340. 2
  2341. rsxuv := {r*u + s*v*x + u ,
  2342. 2
  2343. r + s,
  2344. - r + x - 2,
  2345. r + v,
  2346. 2
  2347. v - v - 6}
  2348. roots rsxuv;
  2349. {{r= - 3.0,s= - 9.0,u=1.5 + 4.97493718553*i,v=3.0,x=-1},
  2350. {r= - 3.0,s= - 9.0,u=1.5 - 4.97493718553*i,v=3.0,x=-1},
  2351. {r=2.0,s= - 4.0,u= - 1 + 5.56776436283*i,v= - 2.0,x=4.0},
  2352. {r=2.0,
  2353. s= - 4.0,
  2354. u= - 1 - 5.56776436283*i,
  2355. v= - 2.0,
  2356. x=4.0}}
  2357. %{{r= - 3.0,s= - 9.0,u=1.5 + 4.97493718553*i,v=3.0,x=-1},
  2358. % {r= - 3.0,s= - 9.0,u=1.5 - 4.97493718553*i,v=3.0,x=-1},
  2359. % {r=2.0,s= - 4.0,u= - 1 + 5.56776436283*i,v= - 2.0,x=4.0},
  2360. % {r=2.0,s= - 4.0,u= - 1 - 5.56776436283*i,v= - 2.0,x=4.0}}
  2361. % 138)
  2362. rsxuv2 := {u^2+u*r+s*x,s+r,x-r-2,r+v,v^2-v-6};
  2363. 2
  2364. rsxuv2 := {r*u + s*x + u ,
  2365. r + s,
  2366. - r + x - 2,
  2367. r + v,
  2368. 2
  2369. v - v - 6}
  2370. roots rsxuv2;
  2371. {{r= - 3.0,s=3.0,u= - 0.791287847478,v=3.0,x=-1},
  2372. {r= - 3.0,s=3.0,u=3.79128784748,v=3.0,x=-1},
  2373. {r=2.0,s= - 2.0,u= - 4.0,v= - 2.0,x=4.0},
  2374. {r=2.0,s= - 2.0,u=2.0,v= - 2.0,x=4.0}}
  2375. %{{r= - 3.0,s=3.0,u= - 0.791287847478,v=3.0,x=-1},
  2376. % {r= - 3.0,s=3.0,u=3.79128784748,v=3.0,x=-1},
  2377. % {r=2.0,s= - 2.0,u= - 4.0,v= - 2.0,x=4.0},
  2378. % {r=2.0,s= - 2.0,u=2.0,v= - 2.0,x=4.0}}
  2379. % 139) combining both types of capabilities.
  2380. axyz3 := {a-1,a-1+x^2-x-2,a-1+y^2+y,x^3+y^3+z+5,y^2-x^2};
  2381. axyz3 := {a - 1,
  2382. 2
  2383. a + x - x - 3,
  2384. 2
  2385. a + y + y - 1,
  2386. 3 3
  2387. x + y + z + 5,
  2388. 2 2
  2389. - x + y }
  2390. roots axyz3;
  2391. {{a=1,x=-1,y=-1,z= - 3.0}}
  2392. %{{a=1,x=-1,y=-1,z= - 3.0}}
  2393. % 140) spurious real and imag. parts had to be eliminated from z and y.
  2394. ayz := {a^2+a+1,z^2+a^3+3,y^3-z^2};
  2395. 2 3 2 3 2
  2396. ayz := {a + a + 1,a + z + 3,y - z }
  2397. roots ayz;
  2398. {{a= - 0.5 + 0.866025403784*i,y= - 1.58740105197,z=2.0*i},
  2399. {a= - 0.5 + 0.866025403784*i,y= - 1.58740105197,z= - 2.0*i},
  2400. {a= - 0.5 - 0.866025403784*i,y= - 1.58740105197,z= - 2.0*i},
  2401. {a= - 0.5 - 0.866025403784*i,y= - 1.58740105197,z=2.0*i},
  2402. {a= - 0.5 + 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=2.0*i},
  2403. {a= - 0.5 + 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=2.0*i},
  2404. {a= - 0.5 + 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z= - 2.0*i},
  2405. {a= - 0.5 + 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z= - 2.0*i},
  2406. {a= - 0.5 - 0.866025403784*i,
  2407. y=0.793700525984 - 1.374729637*i,
  2408. z= - 2.0*i},
  2409. {a= - 0.5 - 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z= - 2.0*i},
  2410. {a= - 0.5 - 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=2.0*i},
  2411. {a= - 0.5 - 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=2.0*i}}
  2412. %{{a= - 0.5 + 0.866025403784*i,y= - 1.58740105197,z=2.0*i},
  2413. % {a= - 0.5 + 0.866025403784*i,y= - 1.58740105197,z=-2.0*i},
  2414. % {a= - 0.5 - 0.866025403784*i,y= - 1.58740105197,z=-2.0*i},
  2415. % {a= - 0.5 - 0.866025403784*i,y= - 1.58740105197,z=2.0*i},
  2416. % {a= - 0.5 + 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=2.0*i},
  2417. % {a= - 0.5 + 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=2.0*i},
  2418. % {a= - 0.5 + 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=-2.0*i},
  2419. % {a= - 0.5 + 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=-2.0*i},
  2420. % {a= - 0.5 - 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=-2.0*i},
  2421. % {a= - 0.5 - 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=-2.0*i},
  2422. % {a= - 0.5 - 0.866025403784*i,y=0.793700525984 - 1.374729637*i,z=2.0*i},
  2423. % {a= - 0.5 - 0.866025403784*i,y=0.793700525984 + 1.374729637*i,z=2.0*i}}
  2424. % 141) some small real or imaginary parts are not spurious; they are kept.
  2425. zz:= {x**9-9999x**2-0.01,y^2+y-x};
  2426. 9 2
  2427. 100*x - 999900*x - 1 2
  2428. zz := {------------------------, - x + y + y}
  2429. 100
  2430. roots zz;
  2431. {{x= - 3.35839794887 + 1.61731917877*i,y= - 0.944735689647 - 1.81829254591*i},
  2432. {x= - 3.35839794887 - 1.61731917877*i,y= - 0.944735689647 + 1.81829254591*i},
  2433. {x= - 3.35839794887 + 1.61731917877*i,y= - 0.0552643103532 + 1.81829254591*i},
  2434. {x= - 3.35839794887 - 1.61731917877*i,y= - 0.0552643103532 - 1.81829254591*i},
  2435. {x= - 0.829455794538 + 3.6340832074*i,y= - 1.74509731832 - 1.45935709359*i},
  2436. {x= - 0.829455794538 - 3.6340832074*i,y= - 1.74509731832 + 1.45935709359*i},
  2437. {x= - 0.829455794538 + 3.6340832074*i,y=0.745097318317 + 1.45935709359*i},
  2438. {x= - 0.829455794538 - 3.6340832074*i,y=0.745097318317 - 1.45935709359*i},
  2439. {x=5.00250075018e-29 + 0.00100005000375*i,y
  2440. = - 1.0000010001 - 0.00100004800346*i},
  2441. {x=5.00250075018e-29 - 0.00100005000375*i,y
  2442. = - 1.0000010001 + 0.00100004800346*i},
  2443. {x=5.00250075018e-29 + 0.00100005000375*i,y
  2444. =0.00000100009500904 + 0.00100004800346*i},
  2445. {x=5.00250075018e-29 - 0.00100005000375*i,y
  2446. =0.00000100009500904 - 0.00100004800346*i},
  2447. {x=2.3240834909 + 2.91430845907*i,y= - 2.29755558063 - 0.810630973104*i},
  2448. {x=2.3240834909 - 2.91430845907*i,y= - 2.29755558063 + 0.810630973104*i},
  2449. {x=2.3240834909 + 2.91430845907*i,y=1.29755558063 + 0.810630973104*i},
  2450. {x=2.3240834909 - 2.91430845907*i,y=1.29755558063 - 0.810630973104*i},
  2451. {x=3.72754050502,y= - 2.49437722235},
  2452. {x=3.72754050502,y=1.49437722235}}
  2453. %{{x= - 3.35839794887 + 1.61731917877*i,y= - 0.944735689647 -
  2454. % 1.81829254591*i},
  2455. % {x= - 3.35839794887 - 1.61731917877*i,y= - 0.944735689647 +
  2456. % 1.81829254591*i},
  2457. % {x= - 3.35839794887 + 1.61731917877*i,y= - 0.0552643103532 +
  2458. % 1.81829254591*i},
  2459. % {x= - 3.35839794887 - 1.61731917877*i,y= - 0.0552643103532 -
  2460. % 1.81829254591*i},
  2461. % {x= - 0.829455794538 + 3.6340832074*i,y= - 1.74509731832 -
  2462. % 1.45935709359*i},
  2463. % {x= - 0.829455794538 - 3.6340832074*i,y= - 1.74509731832 +
  2464. % 1.45935709359*i},
  2465. % {x= - 0.829455794538 + 3.6340832074*i,y=0.745097318317 +
  2466. % 1.45935709359*i},
  2467. % {x= - 0.829455794538 - 3.6340832074*i,y=0.745097318317 -
  2468. % 1.45935709359*i},
  2469. % {x=5.00250075018E-29 + 0.00100005000375*i,y= - 1.0000010001 -
  2470. % 0.00100004800346*i},
  2471. % {x=5.00250075018E-29 - 0.00100005000375*i,y= - 1.0000010001 +
  2472. % 0.00100004800346*i},
  2473. % {x=5.00250075018E-29 + 0.00100005000375*i,y=0.00000100009500904 +
  2474. % 0.00100004800346*i},
  2475. % {x=5.00250075018E-29 - 0.00100005000375*i,y=0.00000100009500904 -
  2476. % 0.00100004800346*i},
  2477. % {x=2.3240834909 + 2.91430845907*i,y= - 2.29755558063 -
  2478. % 0.810630973104*i},
  2479. % {x=2.3240834909 - 2.91430845907*i,y= - 2.29755558063 +
  2480. % 0.810630973104*i},
  2481. % {x=2.3240834909 + 2.91430845907*i,y=1.29755558063 + 0.810630973104*i},
  2482. % {x=2.3240834909 - 2.91430845907*i,y=1.29755558063 - 0.810630973104*i},
  2483. % {x=3.72754050502,y= - 2.49437722235},
  2484. % {x=3.72754050502,y=1.49437722235}}$
  2485. % 142) if quotient, only numerator is used as polynomial, so this works.
  2486. vv := {x+1+1/x,y^2-x^3};
  2487. 2
  2488. x + x + 1 3 2
  2489. vv := {------------, - x + y }
  2490. x
  2491. roots vv;
  2492. {{x= - 0.5 + 0.866025403784*i,y=-1},
  2493. {x= - 0.5 - 0.866025403784*i,y=-1},
  2494. {x= - 0.5 + 0.866025403784*i,y=1},
  2495. {x= - 0.5 - 0.866025403784*i,y=1}}
  2496. %{{x= - 0.5 + 0.866025403784*i,y=-1},{x= - 0.5 - 0.866025403784*i,y=-1},
  2497. % {x= - 0.5 + 0.866025403784*i,y=1},{x= - 0.5 - 0.866025403784*i,y=1}}
  2498. % 143) and this also works.
  2499. ii := {x^2-2x+3/r,r^3-5};
  2500. 2
  2501. r*x - 2*r*x + 3 3
  2502. ii := {------------------,r - 5}
  2503. r
  2504. roots ii;
  2505. {{r= - 0.854987973338 + 1.48088260968*i,x= - 0.464963274745 - 0.518567329174*i},
  2506. {r= - 0.854987973338 - 1.48088260968*i,x= - 0.464963274745 + 0.518567329174*i},
  2507. {r= - 0.854987973338 + 1.48088260968*i,x=2.46496327474 + 0.518567329174*i},
  2508. {r= - 0.854987973338 - 1.48088260968*i,x=2.46496327474 - 0.518567329174*i},
  2509. {r=1.70997594668,x=1 + 0.868568156754*i},
  2510. {r=1.70997594668,x=1 - 0.868568156754*i}}
  2511. %{{r= - 0.854987973338 + 1.48088260968*i,x= - 0.464963274745 -
  2512. % 0.518567329174*i},
  2513. % {r= - 0.854987973338 - 1.48088260968*i,x= - 0.464963274745 +
  2514. % 0.518567329174*i},
  2515. % {r= - 0.854987973338 + 1.48088260968*i,x=2.46496327474 +
  2516. % 0.518567329174*i},
  2517. % {r= - 0.854987973338 - 1.48088260968*i,x=2.46496327474 -
  2518. % 0.518567329174*i},
  2519. % {r=1.70997594668,x=1 + 0.868568156754*i},
  2520. % {r=1.70997594668,x=1 - 0.868568156754*i}}
  2521. % 144)
  2522. bb := {y+x+3,x^2+r+s-3,x^3+r+s-7,r^2-r,s^2+3s+2};
  2523. bb := {x + y + 3,
  2524. 2
  2525. r + s + x - 3,
  2526. 3
  2527. r + s + x - 7,
  2528. r*(r - 1),
  2529. 2
  2530. s + 3*s + 2}
  2531. roots bb;
  2532. {{r=0,s=-1,x=2.0,y= - 5.0},
  2533. {r=1,s= - 2.0,x=2.0,y= - 5.0}}
  2534. %{{r=0,s=-1,x=2.0,y= - 5.0},{r=1,s= - 2.0,x=2.0,y= - 5.0}}
  2535. end;
  2536. Time for test: 92630 ms, plus GC time: 3504 ms