How can I force simplify function I want?

3 ビュー (過去 30 日間)
Ismail Taygun Bulmus
Ismail Taygun Bulmus 2020 年 12 月 16 日
コメント済み: Star Strider 2020 年 12 月 18 日
I have a problem about both simplify and subs functions.
  1. Simplify function is not working in the following example.
syms mu B cc M M_bar E V_N sigma_1;
sigma_1 = sqrt((M+M_bar-4*E*V_N)^2+(2*mu*B)^2);
cantSimplified_Var = simplify(sqrt(4*B^2*mu^sym(2) + 16*E^sym(2)*V_N^2 - 8*E*M*V_N - 8*E*M_bar*V_N + M^2 + 2*M*M_bar + M_bar^2));
isequal(expand(sigma_1),cantSimplified_Var)
ans =
logical
1
isequal(sigma_1,cantSimplified_Var)
ans =
logical
0
2. I want to continue with my new defined function. For example,
syms A B C
A = B^2;
C = A + B^2
C =
2*B^2
Here, I want to see equation like "C = 2*A". Is it possible?
It is related to my first question, because if I can see the expression like "C = 2*A", I will continue my calculation whether MATLAB simplify it correctly or not.

採用された回答

Star Strider
Star Strider 2020 年 12 月 16 日
Tell MATLAB to keep slimplfying until it cannot simplify it further (or reaches the iteration limit), then test equality with the isAlways function:
syms mu B cc M M_bar E V_N sigma_1;
sigma_1 = sqrt((M+M_bar-4*E*V_N)^2+(2*mu*B)^2);
cantSimplified_Var = simplify(sqrt(4*B^2*mu^sym(2) + 16*E^sym(2)*V_N^2 - 8*E*M*V_N - 8*E*M_bar*V_N + M^2 + 2*M*M_bar + M_bar^2), 'Steps',500);
Test = isAlways(sigma_1 == cantSimplified_Var)
producing:
Test =
logical
1
.
  4 件のコメント
Ismail Taygun Bulmus
Ismail Taygun Bulmus 2020 年 12 月 18 日
Okay, thank you again.
Star Strider
Star Strider 2020 年 12 月 18 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by