# How to find the root of the equation which contains imaginary I in it

ClearAll["Global*"]
zz = FullSimplify[-(((0. + 396232. I) x Cos[
0.000198116 Sqrt[x^2]] Csc[(Sqrt[157/10] Sqrt[x^2])/20000])/
Sqrt[x^2]) - (I (x^2)^(3/4))/(4945.28 x Csc[
0.186346 (x^2)^(1/4)] Sin[0.0621153 (x^2)^(1/4)] Sin[
0.124231 (x^2)^(1/4)] -
4945.28 x Csch[0.186346 (x^2)^(1/4)] Sinh[
0.0621153 (x^2)^(1/4)] Sinh[0.124231 (x^2)^(1/4)])]
Plot[{Re[zz], Im[zz]}, {x, 0, 100000}]
FindRoot[zz == 0, {x, 8000}]

I wanted to find the root of this equation but seems like NSolve is not working for these kinds of equation. How to deal about these kind of situation. I tried NSolve but it is failing. Findroot function is working but demands initial guess all the time. How to implement NSolve for this kind of problem.

You can specify the region where to look for the solutions:

NSolve[0 == zz && Abs[x] < 100000, x]

(*{{x -> -87215.4 + 0. I}, {x -> -71358. + 0. I}, {x -> -55500.7 +
0. I}, {x -> -39643.3 + 0. I}, {x -> -23786. +
0. I}, {x -> -7928.67 + 0. I}, {x -> 7928.67 + 0. I}, {x ->
23786. + 0. I}, {x -> 39643.3 + 0. I}, {x -> 55500.7 + 0. I}, {x ->
71358. + 0. I}, {x -> 87215.4 + 0. I}}*)
• Tricky solution! The result is real and I'm wondering why NSolve[0 == zz && 0 < x < 100000, x , Reals] fails. Nov 17, 2018 at 13:11
• According to the manual, In NSolve[expr,vars,Reals] all variables, parameters, constants, and function values are restricted to be real. So technically, since the function is complex valued, you should use NSolve[0 == z && x \[Element] Reals && 0 < x < 100000, x, Complexes]. Nevertheless it fails. I would guess it has something to do with the way MMA deals with expressions like $\sqrt{x^2}$. Nov 18, 2018 at 14:26
• @ yuriyi Thanks! Nov 18, 2018 at 14:45

I don't know why NSolve fails. Here is a workaround which uses the datapoints used in Plot

pict = Plot[{Im[zz], 0}, {x, 0, 100000}, MaxRecursion -> 5 ]
(* added "0" as second argument *)

np = GraphicsMesh`FindIntersections[pict[[All, 1]]  ];
(* intersection points Im[zz] and 0 *)
(*{{7929.56, 7.27596*10^-12}, {23786.7, 0.}, {39643.5,7.27596*10^-12},
{55500.7, -3.63798*10^-12}, {71358., 0.}, {87215.5,0.}}*)

These are the points Im[zz]==0!

Show[{pict, Graphics[{Red, PointSize[Large], Point[np]}]}]

If you need more precision you can take the result as Starting values inside FindRoot.