How Can I Use plot2d code for presence of singularities?
Subject: How Can I Use plot2d code for presence of singularities?
From: Raymond Toy
Date: Mon, 24 Dec 2012 15:09:52 -0800
>>>>> "Edwin" == Edwin Woollett <woollett at charter.net> writes:
Edwin> If I use plot2d(1/sin(x),[x,-1,1]), I immediately get the
Edwin> screen response:
Edwin> "plot2d: expression evaluates to non-numeric value
Edwin> somewhere in plotting range."
Edwin> How can I use the plot2d code (only) to capture this
Edwin> message, and thus quickly detect a singularity in
Edwin> an arbitrary function (either in interactive use or
Edwin> in a user defined function)?
Well, you can't, directly. After peeking at draw2d (where the error
message comes from), it looks like you'll have to call adaptive-plot
appropriately and then check to see if the returned result has any
non-numbers in it. I think that will also tell you where the bad
point is, roughly.
But adaptive-plot can fail in many different ways, like, for example,
you try plot2d(x*k,[x,-1,1]), where k is not defined anywhere. Plot2d
just says theres a non-numeric value somewhere, where, in fact, it's
everywhere.
I think there are also cases where adaptive-plot misses some
singularities.
So, as a method to find singularities, it will probably do a better
job than quad_gags, but it's not perfect either. For example,
plot2d(x/(1/2-x)^3,[x,0,.999999]) doesn't produce any warnings. The
graph does show, of course, a possible singular point near x = 1/2.
Ray