Same if you Plot[Re[eq], {h, -1, 1}].
–
b.gatessucksJan 23 '13 at 11:31

Thank you. Actually the equation I am using is much longer, it has reals solutions, which I obtained by picking up only the real solutions. To speed up my algorithm I wanted to force findroot itself to return only real solutions
–
Fabio Dalla LiberaJan 23 '13 at 11:43

With the complete equation I am using, NSolve does not return
–
Fabio Dalla LiberaJan 23 '13 at 11:45

1 Answer
1

Real solutions

For a general technique of using FindRoot the way you would like I recommend to read this post : First positive root. However in order to demonstrate how it works for real numbers we should have a different equation since this one has no real solutions :

NSolve[ eq[h] == 0, h, Reals]

{}

Sometimes it is reasonable to restrict the search for roots to a special region, e.g. if we add an inequality 0 < h < 3 then we don't have to specify the domain Reals because the system understands that h must be real :

NSolve[ eq[h] == 0 && 0 < h < 3, h ]

General remarks on using NSolve you could find here : Solve an equation in R+
since they are valid for Solve as well as for NSolve.

For the function f we can find a global minimum of the real part :

nmin = { h /. #[[2]], #[[1]]}& @ NMinimize[ Re @ eq[h], h]

{-1.83596, 0.100607}

For an idea what we can expect let's plot the real and imaginary parts of f :

The green points denote the complex roots, you can see that there are no real roots. The red lines are solutions to Re[ eq[h] ] == 0 while the cyan lines denote solutions to Im[ eq[h] ] == 0. One can see a that there are some branch cuts on the plots, i.e. the definition of the function eq is reliable only if we use it in appropriate regions in the complex plane.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.