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!
Rootobjects are exact. You can't get higher precision than that. You can get lower precision, though, withN[roots, 30]etc., as you probably know. – Michael E2 Oct 31 '15 at 22:21NSolveto numerically solve for roots, not return unsolvedRootobjects. – Jerry Guern Oct 31 '15 at 22:25NumericQ[Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 1]]. -- Or maybe, if I ask this way, I will understand what you want: If a root is, say,Sqrt[2], what answer do you want to get instead of the unsolved square root? -- Or maybe this would clear things up: There is no greatest finite precision, and to get infinite precision is the same as to get an exact answer, i.e.Root[..]. – Michael E2 Oct 31 '15 at 22:32Sqrt[2]is not a valid example, because high-order polynomials don't generally have exact solutions. So high-precision numerical answers and unsolved Roots are the only possible results. – Jerry Guern Oct 31 '15 at 22:56N[Root[1 + 2 #1^2 + 3 #1^3 + 3 #1^4 + 3 #1^5 + #1^6 &, 1], 2 10^7]; //AbsoluteTiming) – Michael E2 Oct 31 '15 at 22:59Rootobjects are returned bySolve, not byNSolve. – Daniel Lichtblau Nov 01 '15 at 02:32Rootobjects 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. – Daniel Lichtblau Nov 01 '15 at 02:34Rootobjects were also given by infinite precisionNSolve. Suffice it to say that infinite precisionNSolveis, to good approximation, another exact version of Solve`. – Daniel Lichtblau Nov 01 '15 at 02:36Out[123]= 1.26765*10^30`.
– Daniel Lichtblau Nov 01 '15 at 02:46Out[133]= 2.08111*10^36`
– Daniel Lichtblau Nov 01 '15 at 17:30