MathGroup Archive 2011

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

Search the Archive

Unexpected behavior of Plot3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116505] Unexpected behavior of Plot3D
  • From: Alexey <lehin.p at gmail.com>
  • Date: Thu, 17 Feb 2011 05:19:50 -0500 (EST)

Hello,

According to the documentation for Plot3D, combination of options
PlotPoints -> 25 and MaxRecursion -> 0 should result in computing a
rectangular grid of values of the function with dimensions 25x25. In
some cases it seems to be true:

In[1]:=
Reap[Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 25,
    MaxRecursion -> 0,
    EvaluationMonitor :> Sow[{x, y}]]][[2, 1]] // Length

Out[1]= 625

But if we call the same function through a definition, say f[x_, y_] =
Sin[x y], we get unexpected and enormous increasing of the number of
evaluations of the function:

In[1]:= f[x_, y_] = Sin[x y];
pts = Reap[
    Plot3D[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 25,
     MaxRecursion -> 0, EvaluationMonitor :> Sow[{x, y}]]][[2, 1]];
pts // Length
ListPlot[pts]
Union[pts, SameTest -> (Abs[Norm[#1 - #2]] < 10^-7 &)] // Length

Out[3]= 2500

Out[4]= - Graphics -

Out[5]= 625

As you can see the most of the points differ from each other with norm
< 10^-7. These points are so close that cannot be discerned by eye
from each other and obviously do not improve the plot.

So I'm wondering what is the reason for such behavior? Is there a way
to switch it off?


  • Prev by Date: Re: Another point about Mathematica 8.0
  • Next by Date: Re: Another point about Mathematica 8.0
  • Previous by thread: Re: How to get last input line in MathLink mode?
  • Next by thread: Re: 3D surface plots - non deletion of data inside undesirable