gpt4 book ai didi

wolfram-mathematica - 数学中的误导性情节问题

转载 作者:行者123 更新时间:2023-12-04 08:14:08 25 4
gpt4 key购买 nike

我想通过在mathematica 中绘制出一些“奇怪”的函数来研究它们。一个例子如下:

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}]

但是,我从 mma 得到的图具有误导性,因为 fn[x, 5] 的最大值和最小值应该在相同的两个级别上。但是由于函数的高振荡,以及显然 mma 只需要有限数量的点来绘制函数的事实,您会看到该图表现出奇怪的行为。有没有什么方案可以解决这个问题?

plot of fn

非常感谢。

最佳答案

您需要稍微增加 PlotPoints 的设置才能获得“好”的结果。

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

(我也颠倒了函数的顺序,以便能够看到所有的曲线。) enter image description here

关于wolfram-mathematica - 数学中的误导性情节问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5200249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com