Solving for the roots of a huge polynomial with NSolve
One way is to treat Exp[10 I x]
as an independent variable u
, solve for x
as a polynomial equation, then substitute u
back in and solve for x
:
eqn = -1.0*x^10 + 2.27240187833694*^-8*I*x^9*Exp[10*I*x] +
7.68437888416966*I*x^9 + 1.73169574087938*^-7*x^8*Exp[10*I*x] +
23.4044813384511*x^8 - 5.20791054835238*^-7*I*x^7*Exp[10*I*x] -
36.0135696807004*I*x^7 - 7.85132730855641*^-7*x^6*Exp[10*I*x] -
29.5154618492716*x^6 + 6.20597585823453*^-7*I*x^5*Exp[10*I*x] +
12.3892478542342*I*x^5 + 2.4192289009764*^-7*x^4*Exp[10*I*x] +
2.37763308768566*x^4 - 3.85882723801709*^-8*I*x^3*Exp[10*I*x] -
0.220408659392789*I*x^3 - 2.54561372137026*^-9*x^2*Exp[10*I*x] -
0.0102441292522529*x^2 + 7.03100112140431*^-11*I*x*Exp[10*I*x] +
0.000227506852973307*I*x + 6.82223646304564*^-13*Exp[10*I*x] +
1.91620993166503*^-6 == 0;
sol = Solve[eqn /. Exp[10*I*x] -> u, x];
sols = Check[FindRoot[Equal @@@ # /. u -> Exp[10*I*x], {x, 1 + I}], Nothing] & /@ sol
sols = FindRoot[Equal @@@ # /. u -> Exp[10*I*x], {x, 5 + I}] & /@ sol
(*
{{x -> 0. + 0.026696 I}, {x -> 0. + 0.026696 I}, {x -> 0. + 0.0577141 I},
{x -> 0. + 0.0638266 I}, {x -> 0. + 0.142966 I}, {x -> -9.19269*10^-25 + 0.991696 I},
{x -> 0. + 0.991696 I}, {x -> 0. + 1.1697 I}, {x -> 0. + 2.1067 I}, {x -> 0. + 2.1067 I}}
*)
Check:
eqn /. Equal -> Subtract /. sols
(*
{1.2191*10^-20 + 0. I, 1.20619*10^-20 + 0. I, -8.47033*10^-22 + 0. I,
-1.01644*10^-20 + 0. I, -2.98156*10^-19 + 0. I, -2.84217*10^-14 + 2.35099*10^-38 I,
-2.13163*10^-14 + 0. I, -1.77636*10^-14 + 0. I, -7.95808*10^-13 + 0. I,
-1.13687*10^-13 + 0. I}
*)
You can use NSolve, you only have to restrict the solution range:
sol = NSolve[{eqn == 0, -3 < Re[x] < 3, -3 < Im[x] < 3}, x, Complex]
(*{{x -> -2.92574 - 1.88571 I}, {x -> -2.28599 - 1.86965 I},
{x -> -1.64163 - 1.85254 I}, {x -> -0.990534 -1.83619 I},
{x -> -0.331534 - 1.8251 I}, {x -> -3.99702*10^-7 +0.991696 I},
{x -> -4.57485*10^-9 + 0.026696 I}, {x -> 0. + 0.0577141 I},
{x -> 0. + 0.0638266 I}, {x ->0. + 0.142966 I}, {x -> 0. + 1.1697 I},
{x -> 0. + 2.1067 I}, {x ->0. + 2.1067 I},
{x -> 4.57485*10^-9 +0.026696 I}, {x ->3.99702*10^-7 + 0.991696 I},
{x -> 0.331534 - 1.8251 I}, {x -> 0.990534 - 1.83619 I},
{x -> 1.64163 - 1.85254 I}, {x -> 2.28599 - 1.86965 I}, {x -> 2.92574 -1.88571 I}}*)
verification of the solution:
zw = ComplexExpand[{Re[#], Im[#]} &[ eqn /. x -> rex + I imx],TargetFunctions -> {Re, Im}];
Show[{ContourPlot[{zw[[1]] == 0, zw[[2]] == 0} // Evaluate, {rex, -3,3}, {imx, -3, 3}, ContourStyle -> {Blue, Red}, MaxRecursion -> 4], Graphics[{Darker[Green], PointSize[.02],Point[{Re[x], Im[x]} /. sol]}]}, FrameLabel -> {Re[x], Im[x]}]