I've already plowed through the documentation and a bunch of other Questions on this, but I've only found partial or tangentially related answers.
I need numerical results for all of the complex roots of high-order polynomials with real coefficients. But Solve[]
give really bad results, for example:
z[n_, c_] := If[n > 1, z[n - 1, c]^2 + c, c];
expr = z[8, c] // Expand; (*Example polynomial*)
numericRoots = Solve[expr == 0, c] // N;
expr /. numericRoots // Abs // Max
The result should be zero, but the numerical solutions numericRoots
are so far off that the result is:
(* 1.5218*10^34 *)
Because of the high orders, I need to MMa to return the most precise results possible and express them as precisely as possible. I thought this was the way:
r = SetPrecision[NSolve[1 + 2*c^2 + 3*c^3 + 3*c^4 + 3*c^5 + c^6 == 0, c, WorkingPrecision -> Infinity], Infinity]
But that doesn't actually solve the polynomial for some reason:
(* {{c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 1]}, {c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 2]}, {c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 3]}, {c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 4]}, {c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 5]}, {c -> Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 6]}} *)
I can get numerical results by doing this:
c /. r // N
But I'm not sure that all those high-precision instructions I made in the NSolve[]
command above actually made it into these numbers. This isn't a big issue for 6th order polynomials, but it becomes one for 1000th order or so.
So, why didn't my NSolve[]
command solve what I wanted it to solve?
And how can I get the highest-precision numerical roots I want?
The code in my first example (which is supposed to return 0) is a good test of whether or not a proposed solutions is working right.
Thanks!
N[Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 1], 2 10^7]; //AbsoluteTiming
) $\endgroup$Root
objects are returned bySolve
, not byNSolve
. $\endgroup$Root
objects in the indicated result are in no sense "unresolved". They encode numeric approximations, isolating intervals, and can be refined (viaN[...,...]
) to arbitrarily high precision, subject only to computer and bignum numerics limitations. $\endgroup$