0
$\begingroup$
 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.

$\endgroup$

2 Answers 2

3
$\begingroup$

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}}*)
$\endgroup$
3
  • 1
    $\begingroup$ Tricky solution! The result is real and I'm wondering why NSolve[0 == zz && 0 < x < 100000, x , Reals] fails. $\endgroup$ Commented Nov 17, 2018 at 13:11
  • 1
    $\begingroup$ 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}$. $\endgroup$
    – yuriyi
    Commented Nov 18, 2018 at 14:26
  • $\begingroup$ @ yuriyi Thanks! $\endgroup$ Commented Nov 18, 2018 at 14:45
1
$\begingroup$

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 = Graphics`Mesh`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]}]}]

enter image description here

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.