simplify symbolic trigonometric expression

I get a big and jumbled up symbolic output and there are many cos and sines but they dont simplify although I can spot many places where they can combine. Below is a small example where just b is simplified as intended but (b+1) is not.
I know I can add steps but the one below is just an example, I have a big expression (a PART of it is shown below) and I tried even 10k steps but no luck, not to mention that it takes forever with steps added.
If anyone has any ideas then I would be thankful.
actual expression - 50*cos(a) - 50*sin(a) + 425*cos(a)*sin(b) - 100*sin(a)*sin(d)*sin(e) + 100*sin(b + c)*cos(a)*cos(e) + 425*cos(a)*cos(b)*sin(c) + 425*cos(a)*cos(c)*sin(b) + 100*cos(a)*cos(b)*cos(c)*cos(d)*sin(e) - 100*cos(a)*cos(d)*sin(b)*sin(c)*sin(e)
I can spot 2 terms that can combine but it doesnt happen for some reason.
syms x y z k m
b = cos(y)*cos(z)*cos(x) - sin(y)*sin(z)*cos(x)
b = 
simplify(b)
ans = 
simplify(b+1)
ans = 

回答 (1 件)

Ishu
Ishu 2023 年 8 月 31 日

0 投票

Hi Mohd Aaquib,
You can resolve this by breaking down the equation means you can combine the similar expressions and then simplify those parts separately and then at last you can combine then and then simplify the whole expression.
Like in your expression you can breakdown as:
syms a b c d e
eq1 = 50*cos(a) - 50*sin(a);
eq1 = simplify(eq1)
eq1 = 
eq2 = simplify(425*cos(a)*sin(b))
eq2 = 
eq3 = simplify(- 100*sin(a)*sin(d)*sin(e) + 100*sin(b + c)*cos(a)*cos(e))
eq3 = 
eq4 = simplify(425*cos(a)*cos(b)*sin(c) + 425*cos(a)*cos(c)*sin(b))
eq4 = 
eq5 = simplify(100*cos(a)*cos(b)*cos(c)*cos(d)*sin(e) - 100*cos(a)*cos(d)*sin(b)*sin(c)*sin(e))
eq5 = 
Now you can combine these equations('eq1' to 'eq5') and then simplify the whole expression. Or you can also look for more similar expressions like in 'eq2' and 'eq4', simplify these first and then simplify the whole result.
For more information you can refer to this documentation:
Hope it helps!

5 件のコメント

Mohd Aaquib Khan
Mohd Aaquib Khan 2023 年 8 月 31 日
Hi, Thanks for the answer. Yes we cn simplify it individually, I have shown that in my example, but if I just add 1 to the expression it no longer simplifies it. That was my actual doubt.
Also, this was just an example, my actul expressions were have 40-50 terms and its not possible for me to identify terms that can group up.
Torsten
Torsten 2023 年 8 月 31 日
Also, this was just an example, my actul expressions were have 40-50 terms and its not possible for me to identify terms that can group up.
I can assure you that the Symbolic Toolbox will not be able to do what you want it to do in this case.
Mohd Aaquib Khan
Mohd Aaquib Khan 2023 年 8 月 31 日
Yea I thought so, but did not expect that just adding +1 would make the whole simplification fail.
even simplify(b+1,'Steps', 1000) doesnt work
Torsten
Torsten 2023 年 8 月 31 日
And would it have helped for your 40-50 terms long expression ? I guess, no.
Ishu
Ishu 2023 年 10 月 3 日
編集済み: Ishu 2023 年 10 月 3 日
Can I get to know what output are you actually expecting after using "simplify()" on your actual expression? It will be very helpful.

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

製品

リリース

R2022a

質問済み:

2022 年 10 月 24 日

編集済み:

2023 年 10 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by