I use NSolve to find a roots of the trigonometric equation in the following function:
getroots[p_, q_, h_] :=
res = NSolve[
Sin[2*t] - 2*h*(Cos[p]*Cos[t]*Sin[q] - Sin[t]*Cos[q]) == 0, t];
t /. res]
When I evaluate this separately - everything is OK. But if I put it inside some standard Mathematica function (like Plot, NIntegrate etc) relative to arbitrary range of variable p, Mathematica kernel is crushed. The same happens if I try some range of variable q with p<>0. At the same time evaluating relative to any arbitrary range of h>0 does not lead to damage. Of course I can calculate appropriate list of values of getroots and use it in ListPlot or hand-made numerical calculation function, but 1) it is a bit tiresomely 2) I want to understand what is the cause of the error.
Thank everybody in advance!