misleading plot issue in mathematica

Posted by Qiang Li on Stack Overflow See other posts from Stack Overflow or by Qiang Li
Published on 2011-03-04T23:06:00Z Indexed on 2011/03/04 23:24 UTC
Read the original article Hit count: 186

Filed under:

I want to study some "strange" functions by plotting them out in mathematica. One example is the following:

mod2[x_] := Which[Mod[x, 2] >= 1, -2 + Mod[x, 2], True, Mod[x, 2]];
f[x_] := Which[-1 <= x <= 1, Abs[x], True, Abs[mod2[x]]];
fn[x_, n_] := Sum[(3/4)^i*f[4^n*x], {i, 0, n}]
Plot[{fn[x, 0], fn[x, 1], fn[x, 2], fn[x, 5]}, {x, -2, 2}]

However, the plot I got from mma is misleading, in the sense that the maxima and minima of fn[x, 5] should be on the same two levels. But due to high oscillation of the function, and the fact that clearly mma only takes limited number of points to draw the function, you see the plot exhibit strange behavior. Is there any option in plot to remedy for this?

plot of fn

Many thanks.

© Stack Overflow or respective owner

Related posts about mathematica