simplifying symbolic expression in terms of other variables

19 ビュー (過去 30 日間)
Clive Mingham
Clive Mingham 2012 年 6 月 15 日
This is a simplified problem to illustrate what I need: Given the symbolic expression a^2+b^2+2ab+a+b+1 and the definition x=a+b how do I simplify the symbolic expression to give the answer in terms of x, i.e. x^2+x+1?
I've played around with the symbolic toolbox without success.

採用された回答

Stefan Wehmeier
Stefan Wehmeier 2012 年 6 月 18 日
You could also try
syms a b x
assume(x== a+b);
F = a^2+b^2+2*a*b+a+b+1;
simplify(F)
  1 件のコメント
Clive Mingham
Clive Mingham 2012 年 7 月 12 日
this didn't work when I tried it in MuPAD

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 6 月 16 日
I do not know how you would best do this in MuPAD. In Maple, you would use the algsubs() routine, which MuPAD does not have.
You could try
simplify(subs(a^2+b^2+2*a*b+a+b+1, a, x-b))
Please note the difference between "ab" and "a*b" in a symbolic expression. a^2+b^2+2ab+a+b+1 is an algebraic expression but not a symbolic expression unless "2ab" is a variable name (which is possible to create in MuPAD, I believe.)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by