Misleading subject matter in mathematics

I want to learn some “weird” functions by building them in math. 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 graph I received from mma is misleading in the sense that the highs and lows fn[x, 5]should be at the same level. But due to the high fluctuation of the function and the fact that it is clear that mma uses only a limited number of points to draw the function, you see that the plot exhibits strange behavior. Is there any plan option to fix this?

plot of fn

Many thanks.

+3
source share
1 answer

You need to slightly increase the setting for PlotPoints in order to get a “good” result.

Plot[Evaluate[
  Reverse[{fn[x, 0], fn[x, 1], fn[x, 2], fn[x, 5]}]], {x, -2, 2}, 
 PlotPoints -> 4000]

(I also reordered the functions to be able to see all the curves). enter image description here

+9
source

Source: https://habr.com/ru/post/1796409/


All Articles