Re: NSolve using crushes mathematica 7
- To: mathgroup at smc.vnet.net
 - Subject: [mg112551] Re: NSolve using crushes mathematica 7
 - From: Bob Hanlon <hanlonr at cox.net>
 - Date: Sun, 19 Sep 2010 05:40:29 -0400 (EDT)
 
getroots uses numeric techniques so you must ensure that it is only called with numeric arguments.
getroots[p_?NumericQ, q_?NumericQ, h_?NumericQ] := ...
Bob Hanlon
---- Piotr Melenev <aq.velo at gmail.com> wrote: 
=============
Hello,
I use NSolve function to find the roots of the trigonometric equation
inside following function:
getroots[ p_ , q_ , h_ ] := Module[ {res},
         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 function separately - it works properly. But if I
embed it into another Mathematica function, like NIntegrate, Plot etc
(which automatically choses values of the variables) relative to p
variable, Mathematica kernel is crushed with APPCRUSH winerror. At the
same time I can calculate appropriate table of values and use it in
ListPlot or in "hand-made" numerical integration function. But it is
tiresomely and besides that I want to understand what is the cause of
the error...
Thank everybody in advance!