Mathematica作图报错,Table[]函数问题f[x_] = Sin[x]Export["e:\\sin(x).jpg",Show[Plot[f[x],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickness [0.003],Black} ],Plot[Table[Normal[Series[f[x],{x,0,n}]],{n,0,15}],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickne
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 08:17:01
Mathematica作图报错,Table[]函数问题f[x_] = Sin[x]Export["e:\\sin(x).jpg",Show[Plot[f[x],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickness [0.003],Black} ],Plot[Table[Normal[Series[f[x],{x,0,n}]],{n,0,15}],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickne
Mathematica作图报错,Table[]函数问题
f[x_] = Sin[x]
Export["e:\\sin(x).jpg",
Show[
Plot[f[x],{x,-2 \[Pi],8 \[Pi]},
PlotStyle -> {Thickness [0.003],Black} ],
Plot[Table[
Normal[Series[f[x],{x,0,n}]],{n,0,15}],{x,-2 \[Pi],
8 \[Pi]},PlotStyle -> {Thickness [0.001],Blue},
PlotRange -> All],
PlotRange -> {-2,2},
AspectRatio -> 1/8,
PlotLabel -> Style[Sin[x],72],
Ticks -> {Table[n \[Pi],{n,-2,8}],{-1,1}},
LabelStyle -> Directive[FontFamily -> "黑体",Bold,72],
AxesStyle -> Directive[Thickness[0.0025],Arrowheads[{0.0,0.02}]]
],
ImageSize -> {5800,840}]
General::ivar:-6.28254 is not a valid variable.>>
怎么实现在一个Table里面输出级数的各阶展开?
Mathematica作图报错,Table[]函数问题f[x_] = Sin[x]Export["e:\\sin(x).jpg",Show[Plot[f[x],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickness [0.003],Black} ],Plot[Table[Normal[Series[f[x],{x,0,n}]],{n,0,15}],{x,-2 \[Pi],8 \[Pi]},PlotStyle -> {Thickne
原因在于函数 Plot 执行的是非标准计算,那个 Table 并没有生成列表,要想实现输出级数的各阶展开,必须改变 Table 语句的执行次序,也就是用 函数 Evaluate 将 Table 语句先于 Plot 执行.
f[x_] = Sin[x];
Export["e:\\sin(x).jpg",
Show[Plot[f[x],{x,-2 \[Pi],2 \[Pi]},
PlotStyle -> {Thickness[0.003],Black}],
Plot[Evaluate[
Table[Normal[Series[f[x],{x,0,n}]],{n,0,15}]],{x,-2 \[Pi],
2 \[Pi]},PlotStyle -> {Thickness[0.001],Blue},
PlotRange -> All],PlotRange -> {-2,2},AspectRatio -> 1/8,
PlotLabel -> Style[Sin[x],72],
Ticks -> {Table[n \[Pi],{n,-2,2}],{-1,1}},
LabelStyle -> Directive[FontFamily -> "黑体",Bold,72],
AxesStyle -> Directive[Thickness[0.0025],Arrowheads[{0.0,0.02}]]],
ImageSize -> {5800,840}]
这就是输出的图像,坐标轴范围稍微改了一下,