Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: How does Plot work?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115200] Re: How does Plot work?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 4 Jan 2011 04:24:48 -0500 (EST)

On 1/3/11 at 3:56 AM, lshifr at gmail.com (Leonid Shifrin) wrote:

>Not that this  answers the question, but it looks to me like this
>behavior has to do with the exact periodicity of Sin and the plot
>limits being multiples of 2 Pi. Somehow, for PlotPoints being
>exactly 50, this breaks the algorithm (I think this is either a bug,
>or at least the algorithm used is unstable in some cases like this
>one). You can see that changing any of the above would result in a
>normal plot:

I don't believe the intent of the original poster was to produce
a normal plot of Sin[x] but instead to learn more about how Plot
sampled the function to be plotted.

The documentation for Plot states the function to be plotted is
initially sampled at equally spaced points as specified by
PlotPoints. This suggests if the plot range is specified to be 0
to n and the number of plot points is specified to be n+1, the
function will be initially sampled at integer values. But this
is clearly not what is happening as can be seen from:

In[58]:= Reap[
   Plot[Sin[Sow[x]], {x, 0, 9}, MaxRecursion -> 0,
    PlotPoints -> 10]][[-1, -1, 3 ;;]]

Out[58]= {1.*10^-6,0.961804,2.00451,2.97812,3.93262,4.96803,5.93435,6.98156,8.00968,9.}

I don't believe this is evidence of a bug or instability of the
algorithm used by Plot. Perhaps it can be seen as an example
where the documentation isn't complete or is misleading. My
guess is the documentation was intended to give an user a
reasonable understanding of what Plot does without going into
all of the details.



  • Prev by Date: Re: pattern bugs and comment on intuitive syntax for the New Year
  • Next by Date: Re: dissabling code segments
  • Previous by thread: Re: How does Plot work?
  • Next by thread: Re: How does Plot work?