フィルターのクリア

Simplify doesn't simplify the way I want it to

5 ビュー (過去 30 日間)
Russell Marki
Russell Marki 2020 年 4 月 22 日
コメント済み: Walter Roberson 2021 年 1 月 28 日
Simplify doesn't combine factors in large expressions and will try to make an expression positive even at the cost of additional terms. I am exporting large vectors into fortran and I want to make it as easy as possible to optimize, which means I want to reduce as many terms as possible in large expressions. Simplify is not doing this with the default settings. I have looked and can't find a solution to this problem. Can somebody point to a setting or function that will accomplish what I am asking?
phi1 = sym('phi1', 'real');
Phi = sym('Phi', 'real');
phi2 = sym('phi2', 'real');
F = sym('F', [1 4], 'real');
assumeAlso(phi1>=0 & phi1<2*pi & Phi>=0 & Phi<=pi & phi2>=0 & phi2<2*pi)
simplify((6^(1/2)*F(1)*sin(2*phi2)*sin(Phi)^2)/4 + (6^(1/2)*F(2)*sin(2*phi2)*sin(Phi)^2)/4 + (6^(1/2)*F(3)*sin(2*Phi)*cos(phi2))/4 + (6^(1/2)*F(4)*sin(2*Phi)*cos(phi2))/4)
simplify((6^(1/2)*F(1)*sin(2*phi2)*sin(Phi)^2)/4 + (6^(1/2)*F(2)*sin(2*phi2)*sin(Phi)^2)/4)
simplify(2*sin(phi2)^2 - 1)
simplify(1 - 2*sin(phi2)^2)
EDIT: I installed maple's matlab toolbox and it had what I wanted in simplify(a, constants) but was jank in a lot of respects.

採用された回答

Tarunbir Gambhir
Tarunbir Gambhir 2021 年 1 月 28 日
By default, 'simplify' only performs one simplification step, and that is why some expressions, like the one in the question, are not fully reduced. However, you can get a better answer by forcing 'simplify' to perform more steps. Go through this section for more clarification.
In situations where increasing the number of steps does not work, I suggest you try alternate simplification functions. For example, in the third case, you can reduce '2*sin(phi2)^2 - 1' using the following:
combine(2*sin(phi2)^2 - 1, 'sincos')
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 1 月 28 日
Also, using rewrite() can be useful.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by