Mathematica 使用返回函数
我确信这非常简单,但我向 Mathematica 询问方程的特征多项式,如下所示:
m={
{0, n, 0, c1},
{R, 0, 4, c2},
{0, R, 0, 0},
{0, 0, R, c4}
}
CharacteristicPolynomial[m,x]
现在,我想将返回的多项式保存为函数,以便稍后可以调用它(大概使用类似 <代码>f[1])。唉,我一直不知道如何做到这一点。
I'm sure this is very simple, but I ask Mathematica for the characteristic polynomial of an equation, as follows:
m={
{0, n, 0, c1},
{R, 0, 4, c2},
{0, R, 0, 0},
{0, 0, R, c4}
}
CharacteristicPolynomial[m,x]
Now, I would like to save the returned polynomial as a function, so I can later call it (presumably with something like f[1]
). Alas, I've been unable to figure out how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
这相当简单。只需执行此
操作即可注意
Set
(< code>=) 不是SetDelayed
(:=
) 强制对CharacteristicPolynomial
求值一次。如果您使用SetDelayed
,那么每次计算f
时都会对其进行计算。This is fairly straightforward. Simply do this
Note the use of
Set
(=
) notSetDelayed
(:=
) which forcesCharacteristicPolynomial
to be evaluated once. If you usedSetDelayed
, then it would be evaluated every timef
is evaluated.