Re: Unexpected "Invalid comparison" error when plotting function defined with a Condition pattern

*To*: mathgroup at smc.vnet.net*Subject*: [mg69264] Re: Unexpected "Invalid comparison" error when plotting function defined with a Condition pattern*From*: "Andrew Moylan" <andrew.j.moylan at gmail.com>*Date*: Mon, 4 Sep 2006 04:47:04 -0400 (EDT)*References*: <ed68td$jgk$1@smc.vnet.net><ed92v5$p46$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Jens, Does Mathematica give a small complex part for 10^y for any y in the range {1,2}? I can't find any y for which it does. Of course there are various ways I can modify my expression until it "works"; my question is really about understanding why Mathematica's Plot function has this behaviour, so that I can predict it and design for it in the future. Cheers, Andrew Jens-Peer Kuska wrote: > Hi, > > just read the error message -- 10^y gaves a small > imaginary part and > > g[x_?NumericQ /; 0 < Chop[x]] := x > > will fix the problem. > > Regards > Jens > > "Andrew Moylan" <andrew.j.moylan at gmail.com> > schrieb im Newsbeitrag > news:ed68td$jgk$1 at smc.vnet.net... > | Hi, > | > | Please consider the following simple function, > defined for positive x > | using a Condition pattern: > | > | g[x_ /; 0 < x] = x; > | > | When I try to plot this function in the > following way: > | > | Plot[Abs[g[10^y]], {y, 1, 2}]; > | > | I unexpectedly receive some "Less::nord : > Invalid comparison with 10. + > | 0. I attempted" errors. Can anyone explain why > this is, and how I > | should best prevent it? > | > | Relevant note: > | Both of the following different plots of g > succeed with no errors: > | Plot[Abs[g[y]], {y, 1, 2}]; > | Plot[g[10^y], {y, 1, 2}]; > | > | Irrelevant note: > | In my actual application, the function g is more > complicated and is > | complex-valued (hence my use of Abs); but the > error is reproducable > | with the very simple real-valued function g as > defined above. > | > | Thanks for any insight you might be able to give > me on this. > | > | Cheers, > | > | Andrew > |