Finding multiple roots of a polynomial
32 views (last 30 days)
John D'Errico on 1 May 2016
You could make it easier if you bothered to tell us that you lack the symbolic toolbox. You could make it even easier if you just got that tool.
R1 = solve(x^3 - x^2 + x + sqrt(x) - 10 == 0)
Warning: Cannot solve symbolically. Returning a numeric approximation instead.
> In solve (line 303)
As solve points out, this is effectively a polynomial of order higher than 4. Therefore there will be NO analytical solution available. So just use vpasolve. We can kill off the root we just found, then repeat.
R2 = vpasolve((x^3 - x^2 + x + sqrt(x) - 10)/(x-R1) == 0)
- 0.57850464588438859334157837785007 - 1.9364293603758539638535819453716i
Rinse and repeat...
R3 = vpasolve((x^3 - x^2 + x + sqrt(x) - 10)/(x-R1)/(x-R2) == 0)
- 0.57850464588438859334157837785007 + 1.9364293603758539638535819453716i
R4 = vpasolve((x^3 - x^2 + x + sqrt(x) - 10)/(x-R1)/(x-R2)/(x-R3) == 0)
Empty sym: 0-by-1
So vpasolve now gives up the ghost.
Oh, yes, you don't have the symbolic toolbox. So use roots. You say that you cannot use roots, because of the sqrt? Not true.
If we transform it using z = sqrt(x), then the polynomial is of the form
z^6 - z^4 + z^2 + z - 10 == 0
rz = roots([1 0 -1 0 1 1 -10]).^2
2.47945022249623 + 0i
-0.782960810756404 - 1.94637511714628i
-0.782960810756404 + 1.94637511714628i
-0.578504645884386 + 1.93642936037585i
-0.578504645884386 - 1.93642936037585i
2.24348069078536 + 0i
Now, some of those presumed roots will not be so. They will be spurious solutions introduced by the sqrt transformation. Drop the extraneous non-roots of the original problem.
rz.^3 -rz.^2 +rz + sqrt(rz) - 10
3.14925402119063 + 0i
1.62172220765055 - 2.40038042022762i
1.62172220765055 + 2.40038042022762i
-3.01980662698043e-14 - 1.82076576038526e-14i
-3.01980662698043e-14 + 1.82076576038526e-14i
2.1316282072803e-14 + 0i
As you can see, the first three roots were not truly roots. Drop them, and you have the same result that vpasolve gave you, but to a lower precision.
Had the problem been a nastier one, with some power other than a sqrt, it would have been more difficult, but there are still ways to solve the problem.