ans = 
How to further utilize the "simplify" function for simplification?
古いコメントを表示
I was simplifying the trigonometric function, but despite using the "simplify" function, the result I obtained is as follows.
However, this result can still be further simplified. Could you please tell me where the problem lies?
5 件のコメント
Could you include your code and describe why you think the result could further be simplified ?
You could try simplify with the 'steps' option:
simplify(expression,'steps',50)
e.g. Sometimes it simplifies further.
John D'Errico
2025 年 8 月 24 日
When you incude only a picture of your expression, we cannot even copy and paste it into MATLAB to try to do something ourselves. And that makes it considerably more difficult to help you. Surely you don't want to make it more difficult to get help?
A picture may paint a thousand words, but not here.
Anyway, simple in your eyes need not be simple in the eyes of a computer.
The 'steps' name-value pair is correct, however I usually give it at least 500 iterations.
theta = sym('theta', [1 5]);
ans = (cos(theta(4))*sin(theta(1)) - prod(cos(theta(1:3)))*sin(theta(4)) + cos(theta(1))*prod(sin(theta(2:4))) *sin(theta(5)))
ans = simplify(ans, 500)
It doesn't appear to be able to be simplified further.
.
Actually, I would add that asking for all responses is my preference. Then I take the one that makes me happy, as opposed to what simplify likes.
theta = sym('theta', [1 5]);
thing = (cos(theta(4))*sin(theta(1)) - prod(cos(theta(1:3)))*sin(theta(4)) + cos(theta(1))*prod(sin(theta(2:4))) *sin(theta(5)))
simplethings = simplify(thing,steps = 20,all=true)
simplethings(6)
simplethings(8)
But to be honest, I've not seen anything that seems very simple.
However, this result can still be further simplified.
Can you show us the further simplification of that expression? It's possible that the simplification you're thinking of is incorrect or incomplete, or that you need to apply certain additional assumptions (real, positive, integer, etc.) to one or more of the variables in order to satisfy your simplification.
For example:
syms x
f = simplify(sqrt(x^2))
You might say "Shouldn't f just be x?" No, as you can see by substituting x = -1 into f.
shouldBeX = subs(f, x, -1)
Now if you added the assumption that the variable was real:
syms y real
f = simplify(sqrt(y^2))
or that the variable was positive, MATLAB can simplify the expression further:
syms z positive
f = simplify(sqrt(z^2))
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
