PolyRoots
PolyRoots finds the roots of a polynomial to any chosen accuracy using Laguerre's Method. The coefficients of the polynomial can be real or complex.
PolyRoots uses my own multi-precision engine, fp. PolyRoots is released as freeware, with no restrictive licenses.
Consider the simple quadratic:
x^2-4x+4
To find its roots enter the coefficients from high to low order, following each coefficient by a Return. You will see:
1
-4
4
Or you can enter the equation as it stands above (or with the terms in any order):
x^2-4x+4 or 4 - 4x + x^2 or -4x+x^2+4 etc.
Accept the "Significant Figures" defaults and click the "Find Roots" button. In "The Roots" you should see:
2 , 0
2 , 0
Polynomial(root):
4.74162503373286e-138 , 0
4.741625033732861e-138 , 0
The listing under "Polynomial(root):" shows the evaluation, using internal precision, of the polynomial for each of the roots. The numbers are a measure of the "goodness" of the roots. They also will approach zero in the limit. If you see evaluations that appear to be too large, you should increase internal accuracy and try again.
Now enter 32 in "Internal:" under "Significant Figures". The calculation will now be done with an internal bit precision of 4 x 32 = 128. The button click should give:
2 , 0
2 , 0
Polynomial(root):
1.175494350822288e-38 , 0
3.526483052466863e-38 , 0
So you see the result of reduced internal bit precision. For some polynomials this may be adequate, but for others you may need a higher internal precision. The default is a bit precision of 4 x 128 = 512.
Consider a polynomial with some complex coefficients:
x^3+(2,3)x^2+(3,-4)x+10
Copy and paste the following into the coefficient text box:
1
2,3
3,-4
10
Or you can copy and paste the polynomial as expressed with x's. Note that for this type of entry complex numbers must be enclosed by parentheses.
Click the Button and note the three distinct complex roots.
Now try:
x^10+1
which gives ten values for (-1)^(1/10). You should find:
0.9510565162951536 , 0.3090169943749474
0.9510565162951536 , -0.3090169943749474
0.5877852522924731 , -0.8090169943749474
0.5877852522924731 , 0.8090169943749474
0 , 1
0 , -1
-0.5877852522924731 , -0.8090169943749474
-0.5877852522924731 , 0.8090169943749474
-0.9510565162951536 , -0.3090169943749474
-0.9510565162951536 , 0.3090169943749474
Polynomial(root):
-4.578604275704964e-140 , 3.187655433322432e-139
2.894350148670482e-139 , 1.418705297172973e-139
2.305148881078305e-142 , -7.384488107868683e-142
-1.04191816382113e-163 , 8.682651365176084e-164
1.212479706986824e-139 , 0
1.215329027702094e-139 , 0
1.959530180466196e-139 , -3.476674561055515e-140
-1.394105056132418e-139 , 1.425846544684089e-139
-5.430246832232027e-142 , -7.294882652157342e-142
-6.310735355675061e-142 , -4.474259184470905e-142
Finally, find the roots of the polynomial:
x^7+8.638x^6+31.977876x^5+65.76783164x^4+81.15750424376x^3+60.089016142079904x^2+24.716615306442200512x+4.357186184021382204544
The results should tell you that the above is the polynomial:
(x+1.234)^7
so, for this case, repeated roots gave no problem.
Dr. Robert M. Delaney
Emeritus Professor of Physics
Saint Louis University
delaneyrm@earthlink.net
delaneyrm@mac.com
delaneyrm@slu.edu