How to further utilize the "simplify" function for simplification?

조회 수: 6 (최근 30일)
ta
ta 2025년 8월 24일
편집: David Goodmanson 2025년 8월 26일
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
John D'Errico
John D'Errico 2025년 8월 24일
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)))
thing = 
simplethings = simplify(thing,steps = 20,all=true)
simplethings = 
simplethings(6)
ans = 
simplethings(8)
ans = 
But to be honest, I've not seen anything that seems very simple.
Steven Lord
Steven Lord 2025년 8월 25일
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))
f = 
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)
shouldBeX = 
1
Now if you added the assumption that the variable was real:
syms y real
f = simplify(sqrt(y^2))
f = 
or that the variable was positive, MATLAB can simplify the expression further:
syms z positive
f = simplify(sqrt(z^2))
f = 
z

댓글을 달려면 로그인하십시오.

채택된 답변

David Goodmanson
David Goodmanson 2025년 8월 25일
편집: David Goodmanson 2025년 8월 26일
How did an overall factor of theta_dot5 in the question later become sin(theta_5) in the comments ?!? Taking the original posting as correct, and ignoring theta_dot5, this is
sin(th1)*cos(th4) - cos(th1)*cos(th2)*cos(th3)*sin(th4) ...
+ cos(th1)*sin(th2)*sin(th3)*sin(th4)
I did the following calculuation by hand since it's straightforward AND because going to symbolic variables, Matlab seems incapable of simplifying this expression at all. Highly disappointing, although I don't think many people contend that Matlab symbolics is very adept at its job.
By inspection the expression becomes
ans1 = sin(th1)*cos(th4) - cos(th1)*cos(th2+th3)*sin(th4)
which already makes progress because it shows that th2,th3 only come in as their sum.
With d = cos(th2+th3), ans1 is of the form
a - b*d = (1/2)((a+b)*(1-d) + (a-b)*(1+d))
and throwing in some basic trig identities you can arrive at
ans2 = sin(th1+th4)*sin((th2+th3)/2)^2 ...
+ sin(th1-th4)*cos((th2+th3)/2)^2 .
ans2 has a symmetric kind of form but whether it is simpler than ans1 is a matter of opinion. I doubt that further simplification is in the cards.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by