通过自动引入时间变量或以任何其他方式来简化非常长的符号表达式 [英] Simplifying a very long symbolic expression by automatically introducing temporal variables or in any other way

查看:106
本文介绍了通过自动引入时间变量或以任何其他方式来简化非常长的符号表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试解决符号数学问题后,我得到一个约有17000个字符的表达式.我正在使用Matlab的符号工具箱,但是我愿意接受任何建议(Mathematica,无论如何).

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.

运行Matlab命令simplifysimple,甚至尝试执行collect都不能改善这种情况(有些情况变得更糟).

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.

推荐答案

可能尝试使用通用子表达式消除(CSE).这是一个抄袭自

Might try common subexpression elimination (CSE). Here is an example cribbed from

获取mathematica来简化另一个方程式的表达

InputForm[Experimental`OptimizeExpression[(3 + 3*a^2 + Sqrt[5 + 6*a + 5*a^2] +
      a*(4 + Sqrt[5 + 6*a + 5*a^2]))/6]]

==>

Out[206]//InputForm=
Experimental`OptimizedExpression[Block[{Compile`$1, Compile`$3, Compile`$4, 
   Compile`$5, Compile`$6}, Compile`$1 = a^2; Compile`$3 = 6*a; 
   Compile`$4 = 5*Compile`$1; Compile`$5 = 5 + Compile`$3 + Compile`$4; 
   Compile`$6 = Sqrt[Compile`$5]; (3 + 3*Compile`$1 + Compile`$6 + 
     a*(4 + Compile`$6))/6]]

这篇关于通过自动引入时间变量或以任何其他方式来简化非常长的符号表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆