获得 mathematica 用另一个方程来简化表达式 [英] Get mathematica to simplify expression with another equation
问题描述
我有一个非常复杂的 mathematica 表达式,我想通过使用一个新的、可能是无量纲的参数来简化它.
I have a very complicated mathematica expression that I'd like to simplify by using a new, possibly dimensionless parameter.
我表达的一个例子是:
K=a*b*t/((t+f)c*d);
(实际表达式非常大,有数千个字符).我想用 p
(the actual expression is monstrously large, thousands of characters). I'd like to replace all occurrences of the expression t/(t+f) with p
p=t/(t+f);
这里的目标是找到一个替代品,以便所有的 t 和 f 都被 p 替代.在这种情况下,替换 p 是一个无量纲化的参数,所以它看起来是一个很好的候选替换.
The goal here is to find a replacement so that all t's and f's are replaced by p. In this case, the replacement p is a nondimensionalized parameter, so it seems like a good candidate replacement.
我一直无法弄清楚如何在 mathematica 中做到这一点(或者如果可能的话).我试过了:
I've not been able to figure out how to do this in mathematica (or if its possible). I tried:
eq1= K==a*b*t/((t+f)c*d);
eq2= p==t/(t+f);
Solve[{eq1,eq2},K]
毫不奇怪,这行不通.如果有一种方法可以强制它以 p,a,b,c,d 的形式解决 K ,这可能会奏效,但我也不知道该怎么做.想法?
Not surprisingly, this doesn't work. If there were a way to force it to solve for K in terms of p,a,b,c,d, this might work, but I can't figure out how to do that either. Thoughts?
编辑 #1 (11/10/11 - 1:30)[删除以简化]
Edit #1 (11/10/11 - 1:30) [deleted to simplify]
好的,新机智.我采用 p=ton/(ton+toff) 并将 p 乘以几个表达式.我知道 p 可以完全消除.新的表达式(就 p 而言)是
OK, new tact. I've taken p=ton/(ton+toff) and multiplied p by several expressions. I know that p can be completely eliminated. The new expression (in terms of p) is
testEQ = A B p + A^2 B p^2 + (A+B)p^3;
然后我替换了 p,并调用了(正常的)FullSimplify,给出了这个表达式.
Then I made the substitution for p, and called (normal) FullSimplify, giving me this expression.
testEQ2= (ton (B ton^2 + A^2 B ton (toff + ton) +
A (ton^2 + B (toff + ton)^2)))/(toff + ton)^3;
最后,我尝试了下面的所有建议,除了最后一个(不确定它是如何工作的!)
Finally, I tried all of the suggestions below, except the last (not sure how it works yet!)
只有消除选项有效.所以我想我会从现在开始尝试这种方法.谢谢.
Only the eliminate option worked. So I guess I'll try this method from now on. Thank you.
EQ1 = a1 == (ton (B ton^2 + A^2 B ton (toff + ton) +
A (ton^2 + B (toff + ton)^2)))/(toff + ton)^3;
EQ2 = P1 == ton/(ton + toff);
Eliminate[{EQ1, EQ2}, {ton, toff}]
A B P1 + A^2 B P1^2 + (A + B) P1^3 == a1
我应该补充一点,如果目标是进行所有可能的替换,而剩下的,我仍然不知道该怎么做.但看起来如果替换可以完全消除一些变量,Eliminate[]效果最好.
I should add, if the goal is to make all substitutions that are possible, leaving the rest, I still don't know how to do that. But it appears that if a substitution can completely eliminate a few variables, Eliminate[] works best.
推荐答案
你试过了吗?
K = a*b*t/((t + f) c*d);
Solve[p == t/(t + f), t]
-> {{t -> -((f p)/(-1 + p))}}
Simplify[K /. %[[1]] ]
-> (a b p)/(c d)
哦,你知道消除
?
Eliminate[{eq1, eq2}, {t,f}]
-> a b p == c d K && c != 0 && d != 0
Solve[%, K]
-> {{K -> (a b p)/(c d)}}
EDIT 2:此外,在这个简单的例子中,同时求解 K
和 t
似乎也能解决问题:>
EDIT 2: Also, in this simple case, solving for K
and t
simultaneously seems to do the trick, too:
Solve[{eq1, eq2}, {K, t}]
-> {{K -> (a b p)/(c d), t -> -((f p)/(-1 + p))}}
这篇关于获得 mathematica 用另一个方程来简化表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!