在 Maple 中以编程方式使用泰勒多项式
我试图在 Maple 中以编程方式使用泰勒多项式,但以下内容似乎不起作用...
T[6]:=taylor(sin(x),x=Pi/4,6);convert(T[6], polynom, x);
f:=proc(x)
convert(T[6], polynom, x);
end proc;
f(1);
以下所有内容也不起作用:
f:=convert(T[6], polynom);
f:=convert(T[6], polynom);f:=convert(T[6], 多项式, x);
f:=x->convert(T[6], 多项式);
>f:=x->convert(T[6], 多项式, x);
.
有没有一种方法可以做到这一点,而无需将 Convert 的输出复制并粘贴到 f
的定义中?
I am trying to use a Taylor polynomial programmatically in Maple, but the following does not seem to work...
T[6]:=taylor(sin(x),x=Pi/4,6);convert(T[6], polynom, x);
f:=proc(x)
convert(T[6], polynom, x);
end proc;
f(1);
All of the following also do not work:
f:=convert(T[6], polynom);
f:=convert(T[6], polynom, x);
f:=x->convert(T[6], polynom);
f:=x->convert(T[6], polynom, x);
.
Is there a way of doing this without copying and pasting the output of convert into the definition of f
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我理解正确的话,这可以实现你想要的:
If I understood you correctly, this accomplishes what you want:
涉及过程和子程序的几个早期答案将为每个输入进行整个泰勒级数推导,以及转换为多项式。这是非常低效的。
您只需要生成泰勒结果并转换为多项式一次。有了这个结果,您就可以创建一个运算符(用它可以对任意数量的输入进行操作,只需评估该点的多项式,但无需重新计算整个泰勒答案)。
下面是创建过程 f 的方法,用它在任何给定点对参数 x 进行计算。它计算(截断的)泰勒级数并仅一次转换为多项式。
Several earlier answers involving procedures and subs will do the entire taylor series derivation, as well as the conversion to polynom, for each and every input. That is highly inefficient.
You only need to produce the taylor result, and convert to polynom, once. With that result in hand you can then create an operator (with which to act on as many inputs as you wish, merely by evaluating the polynomial at the point but without having to recompute the whole taylor answer).
Below is a way to create a procedure f with which to evaluate at any given point for the argument x. It computes the (truncated) taylor series and converts to polynom just once.
将 T 定义为函数也可能是很自然的。
It might also be natural to define T as a function.