MathGroup Archive 2002

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

Search the Archive

Re: Plot[x Sin[x],{-100,100}] Bad {-100,99} Good?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38374] Re: Plot[x Sin[x],{-100,100}] Bad {-100,99} Good?
  • From: "m. r." <schaferk at bellsouth.net>
  • Date: Fri, 13 Dec 2002 04:09:26 -0500 (EST)
  • References: <at4d54$etu$1@smc.vnet.net> <8935cf7e.0212111900.78c801ea@posting.google.com>
  • Sender: owner-wri-mathgroup at wolfram.com

greetings:

what is happening here is Mathematica is showing something about the adaptive
plotting
algorithm. by altering the value of PlotPoints, one can modify the point
selection.

try some examples with different values of PlotPoints. you/ll be
surprised.
try PlotPoints->n  for n=26? n=12 (!)  n=2 (!). what/s going on?

now, get your hands on the points that are being selected by using:

pts = Plot[x Sin[x], {-100,100}][[1,1,1,1]]

the x,y coordinates are:

xpts = Transpose[pts][[1]]
ypts = Transpose[pts][[2]]

now plot these with ListPlot.
you/ll see that the xpts are not uniformly spaced as you might expect.

this 'feature' in the plotting algorithm has been there since the days
of Mathematica on NeXt (that/s when i first saw this)

is it a bug? is it an artifact of the adaptive algorithm and thus
inherent?


m. r.

No spammage wrote:
> 
> "Steven T. Hatton" <hattons at globalsymmetry.com> wrote in message news:<at4d54$etu$1 at smc.vnet.net>...
> > This is Mathematica 4.2 on Linux.  I evaluated Plot[x Sin[x], {-100,100}] and
> > disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed
> > as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11
> > Sin[11]}.  I've also found that the plot from x=-100 to x=99.99 is incorrect.
> > The plot over the range [-100,99] is correct.  What is happening here?  Does
> > this happen on other systems?
> 
> I tried this in 4.0 and saw the same thing.  If you add the directive
> "PlotPoints->100", it fixes it.


  • Prev by Date: Programming language difficulties.
  • Next by Date: Re: Pure recursive functions
  • Previous by thread: Re: Plot[x Sin[x],{-100,100}] Bad {-100,99} Good?
  • Next by thread: ContinuousDistributions bug?