MathGroup Archive 1996

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

Search the Archive

Re: Is there a Bug in Plot function ?

  • To: mathgroup at
  • Subject: [mg5141] Re: [mg5096] Is there a Bug in Plot function ?
  • From: Allan Hayes <hay at>
  • Date: Wed, 6 Nov 1996 01:33:04 -0500
  • Sender: owner-wri-mathgroup at

"Christopher R. Carlen" <crobc at>
T[mg5096] Is there a Bug in Plot function ?

>I plotted a rather simple function via:
>k = 1;
>dk = 0.1;
>W[x_] = 2 Cos[ 2 Pi ( dk/2 x ) ] Sin[ 2 Pi ( k x ) ]
>Plot[ W[x,0] , {x,-20,20}, PlotStyle->{Thickness[0.002]} ]
>and the resulting plot has severe problems, such as straight lines 
>connecting points on the curve where the sinusoidal cycles that
>should have appeared simply were skipped.

Plot starts off with an initial sample of points and adds more  
points in places where something significant seems to be happening.  
This means that it can be fooled.
For example, try

Plot[x(x^2-1), {x,-1,1}, PlotPoints ->3]


Graphics[{{Line[{{-1., 0.}, {0., 0.}, {1., 0.}}]}},

Here the initial selection is the three points {{-1., 0.}, {0.,  
0.}, {1., 0.}}, and the rules used settle for this indicating the  
obvious straight line.

Starting with four points as in

Plot[x(x^2-1), {x,-1,1}, PlotPoints ->4]

Gives the information that something interesting is happening and  
kicks of the insertion of extra points - the result is what we  
expect, and what is given by the default.

Plot[x(x^2-1), {x,-1,1}]

Your example seems OK with PlotPoints -> 50.
Other numbers may be needed for other parameters.

A description of the adaptive sampling used by plot is given in  
"The Mathematica Graphics Guidebook" by Cameron Smith and Nancy  
Blachman, pp 86-102.

Allan Hayes
hay at

  • Prev by Date: Re: mathematica 3.0 comments?
  • Next by Date: Re: mathematica 3.0 comments?
  • Previous by thread: eps graphics in mathematica, preview?
  • Next by thread: Re: Is there a Bug in Plot function ?