MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

ContourPlot, etc.: not every point a Real

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87453] ContourPlot, etc.: not every point a Real
  • From: Will Robertson <wspr81 at gmail.com>
  • Date: Fri, 11 Apr 2008 01:41:52 -0400 (EDT)

Hello,

I just discovered something a little strange and hoped someone here
might be able to shed some light on the matter. (I'm using Mathematica 6.0.1.)

Take this following code. It defines a function and uses it in a
contour plot; the trick is that every value is intercepted on the way
through (I use this in ColorbarPlot to extract max/min values):

fn := #1^3 + #2^2 &
everyNonReal = {};
Eval[x__] := Module[{val = Evaluate@fn@x},
    If[Head@val =!= Real, AppendTo[everyNonReal, val]]; val]
ContourPlot[Eval[x, y], {x, -2, 2}, {y, -2, 2}]
Union@everyNonReal

If every evaluation of fn resulted in a Real (as I would expect), then
the output should be {} as the if statement would never evaluate. But
there's a point in there that's *not* being evaluated, as you can see.

What's going on? Working around this problem results in an extra If
statement for every single evaluated point, a state of affairs I'm not
so fond of.

Many thanks,
Will


  • Prev by Date: Problem for using "Epilog" to plot legend
  • Next by Date: Re: A Problem with Simplify
  • Previous by thread: Re: Problem for using "Epilog" to plot legend
  • Next by thread: Re: ContourPlot, etc.: not every point a Real