通过自动引入时间变量或以任何其他方式简化非常长的符号表达式
在尝试解决符号数学问题后,我得到了大约 17000 个字符的表达式。我正在使用 Matlab 的符号工具箱,但我愿意接受任何建议(Mathematica,无论什么)。
出于显而易见的原因,我不会将表达式直接复制粘贴到问题中。 这里是一个链接。
运行 Matlab
命令 simplify
和 simple
,甚至尝试 collect
也没有改善情况(有些人得到了情况更糟)。
但我想知道,我不关心表达式是否使用时间参数逐步计算。比如:
z1 = a^2*y1;
%Now the expression can be simplified by using z1 as alias!
z1+z1^2 ....
是否有一种自动方法可以使用时间变量进行逐步简化?此外,您能想到的任何其他方法都是可行的。
After attempting to solve a symbolic math problem, I got an expression with about 17000 characters. I am using the symbolic toolbox for Matlab, but I am open to any suggestion (Mathematica, whatever).
For obvious reasons, I won't copy-paste the expression straight into the question. Here is a link instead.
Running the Matlab
commands simplify
and simple
, and even attempts to collect
didn't improve the situation (Some got it worse).
But I am wondering, I don't care if the expression is evaluated in steps, with temporal parameters. Something like:
z1 = a^2*y1;
%Now the expression can be simplified by using z1 as alias!
z1+z1^2 ....
Is there an automatic method to get such a step-by-step simplification with temporal variables? Also, any other method that you can think of is plausible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以尝试公共子表达式消除(CSE)。这是一个摘自
让mathematica用另一个方程简化表达式
==>
Might try common subexpression elimination (CSE). Here is an example cribbed from
Get mathematica to simplify expression with another equation
==>
正如我在评论中所写,Mathematica 的简化工具似乎比 Matlab 中的类似命令更有效。
鉴于您似乎是 Matlab 用户,因此我在这里向您详细说明如何使用 Mathematica 的两个简化命令。
如果您将长表达式定义为
那么您可以使用
最后一个会产生一个漂亮而清晰的表达式,它只有 1535 个字符(听起来很多,但没有那么多变量)。
也许这足以简化您的问题。如果没有,请告诉我们。
As I wrote in my comment, it seems that Mathematica’s simplification tools are more efficient than similar commands in Matlab.
Since it seems that you are a Matlab user, I give you here a detailed instruction how to use just two of the simplification commands of Mathematica.
If you define your long expression as
Then you can use
The last produces a nice and clear expression which has just 1535 characters (sounds much, but there are not so many variables).
Perhaps this is enough simplification for your problem. If not, then let us know.