Re: Weird Plot behavior...
- To: mathgroup at smc.vnet.net
- Subject: [mg22276] Re: [mg22268] Weird Plot behavior...
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Mon, 21 Feb 2000 20:00:47 -0500 (EST)
- Organization: debis Systemhaus
- References: <200002200450.XAA14907@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
dougmckee at my-deja.com schrieb:
>
> I'm getting some strange, seemingly incorrect
> graphs from Mathematica 3:
>
> First I define a simple piecewise continuous
> function:
>
> sf[x_]:=If[x<(1/3),1-3 x,0.5 x - 1/6]
>
> Then I graph its 4th iterate on [0,1] (along with
> y=x):
>
> Plot[{sf[sf[sf[sf[x]]]],x},{x,0,1}]
>
> It's missing some information; in particular, the
> graph only shows 5 fixed points when I know there
> are 7. And when I graph it on [0,2], I _do_ get
> all 7 fixed points, and, yes, they're all on
> [0,1]:
>
> Plot[{sf[sf[sf[sf[x]]]],x},{x,0,2}]
>
> What's going on? Why is the first graph
> incorrect, and the second correct?
>
> Plot[{sf[sf[sf[sf[x]]]],x},{x,0,1},PlotDivision-
> >5]
>
> And here, even though I think I'm setting the
> PlotDivision _lower_ than the default (20), I get
> the right graph!
>
Dear Doug,
there is nothing weird about your Plot, yet this is another proof of
the rule: never believe a computation! Always verify it -- as you did,
Doug.
What happend you can see with
tr = {};
Plot[{AppendTo[tr, x]; AppendTo[tr, x]; sf[sf[sf[sf[x]]]], x}, {x,0,1}];
tr
With the defaults on PlotPoints (==25) (and PlotDivision) the plot point
sampling algorithm simply and accidentially doesn't hit the interval
[0.22, 0.25] where your function "goes down and up again", as you can
see with
Plot[Nest[sf, x, 4], {x, 0.2, 0.28}]
Now any subtle change of PlotPoints and/or PlotDivision will change the
sampling, and if that interval is hit only once _then_ Plot sampling
will go to the minimum.
So PlotPoints -> 24 as well as PlotPoints -> 26 will produce the correct
plot. The Problem is: your function is rapidly varying and you should
(1) take a higher value of PlotPoints from the beginning and (2) always
verify your plot with different values for that.
Besides, it might be interesting to look at
With[{n = 6},
Plot[Evaluate[NestList[sf, x, n]], {x, 0, 1},
PlotStyle -> Prepend[Table[Hue[i], {i, 0., 1., 1/n}],
GrayLevel[0.]],
PlotPoints -> 31]]
and see what happens in that critical domain.
Kind regards, Hartmut
- References:
- Weird Plot behavior...
- From: dougmckee@my-deja.com
- Weird Plot behavior...