roots.rlg 97 KB

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