Simplify doesn't simplify the way I want it to
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Russell Marki
il 22 Apr 2020
Commentato: Walter Roberson
il 28 Gen 2021
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.
0 Commenti
Risposta accettata
Tarunbir Gambhir
il 28 Gen 2021
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 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!