如何解决程序

茱莉亚(Julia)

请帮帮我!有程序operation[f_]它可以正常工作并绘制函数:Cos,Sin。但是,不幸的是,它不适用于E ^ x和Log [E,x]并输出错误,可能是因为输入的函数名称或其他名称不正确;((有什么问题?

spxsin = {-1, -0.35, 0.3, 0.95, 1.6, 2.375, 3.15, 3.925, 4.7, 5.025, 
5.35, 5.675, 6};
spxcos = {-1, -0.75, -0.5, -0.25, 0, 0.775, 1.55, 2.325, 3.1, 3.825, 
4.55, 5.275, 6};
spxlny = {-1, 0.75, 2.5, 4.25, 6};
spxey = {-1, 0.75, 2.5, 4.25, 6};
operation[f_] := Block[{data},
data = Table[{x, f[x]}, {x, -1, 6, 0.1}];
Graphics[{Thick, Blue, Line[data],
Green, Table[Point[{spx[­[i]], f[spx[­[i]]]}], {i, 1, Length[spx]}],
Pink, Opacity[.7], 
Table[Rectangle[{spx[­[i]], f[spx[­[i]]]}, {spx[­[i + 1]], 
f[spx[­[i + 1]]]}], {i, 1, Length[spx] - 1}]
}, Axes -> True]]

Which[ f == Sin, spx := spxsin, f == Cos, spx := spxcos, f == E^x , 
spx := spxlny, f == Log, spx := spxey]

operation[Sin]
operation[Cos]
operation[E^x]
operation[Log]
苏加德

欧拉的E需要输入为Esc EE Esc。在我看来,您输入的是标准E。

还要注意,Exp是Mathematica中的指数函数。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章