Simplify doesn't simplify the way I want it to
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Russell Marki
el 22 de Abr. de 2020
Comentada: Walter Roberson
el 28 de En. de 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 comentarios
Respuesta aceptada
Tarunbir Gambhir
el 28 de En. de 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 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!