       Re: Is there a Bug in Plot function ?

• To: mathgroup at smc.vnet.net
• Subject: [mg5141] Re: [mg5096] Is there a Bug in Plot function ?
• From: Allan Hayes <hay at haystack.demon.co.uk>
• Date: Wed, 6 Nov 1996 01:33:04 -0500
• Sender: owner-wri-mathgroup at wolfram.com

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

>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.

Christopher,
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]

InputForm[%]

Graphics[{{Line[{{-1., 0.}, {0., 0.}, {1., 0.}}]}},
{<options>}]

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 haystack.demon.co.uk
http://www.haystack.demon.co.uk

```

• 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 ?