How to Simplify an symbolic expression

Hi all, I want to simplify this equation
a= 2 atan((-2+Sqrt(4-gama^2 *l^2* M^2-4* gama *l* M^2 *tan(gama/2)+4* tan(gama/2)^2-4 *M^2 *tan(gama/2)^2))/(gama* l* M+2* tan(gama/2)+2* M* tan(gama/2)))
into this form
a= (gama/2)-asin(((gama*l*M)/2)*cos(gama/2)+M*sin(gama/2))
Can anyone help?

7 Comments

Andrew Newell
Andrew Newell on 18 Apr 2017
Edited: Andrew Newell on 18 Apr 2017
Can you rewrite the first equation so it is valid MATLAB syntax? I presume a lot of the spaces imply multiplication, but I'm not sure.
Can anyone please help?
Compare the results of the two expressions for several choices of gamma and M.
If they agree, you can be quite sure that the two expressions are equal.
Best wishes
Torsten.
They are the same expressions but I want to transform the first one into second one.
If "simplify" on the first expression doesn't help, the question is not MATLAB related.
Best wishes
Torsten.
Or maybe this can help:
https://de.mathworks.com/help/symbolic/isequaln.html
Best wishes
Torsten.
This is basically a tool for checking equivalence but that is not I am after. Thanks.

Sign in to comment.

Answers (2)

If I define
a= 2*atan((-2+sqrt(4-gama^2 *l^2* M^2-4* gama *l* M^2 *tan(gama/2)+4* tan(gama/2)^2-4 *M^2 *tan(gama/2)^2))/(gama* l* M+2* tan(gama/2)+2* M* tan(gama/2)));
b = (gama/2)-asin(((gama*l*M)/2)*cos(gama/2)+M*sin(gama/2));
and substitute pi for gama,
subs(a,gama,pi)
subs(b,gama,pi)
I get a==NaN and b==pi/2 - asin(M). So they are not the same. I find that applying simplify to a does not change it significantly.

5 Comments

its because a has sqrt in it so it s giving imaginary values thats why I wanted to simplify a
Is there some reason that it shouldn't be giving imaginary values?
I am not quite sure but I want to rewrite the equation a to eliminate sqrt.
I still don't understand why you try to transform the first expression into the second if - as you write - you are sure that both expressions yield the same values for a (at least in cases where both expressions are real-valued).
Best wishes
Torsten.
Hi Torsten,
I want to transform the first expression because second one is more compact and easy to read.

Sign in to comment.

I randomly substituted M=2, l=3. With those two values, the two expressions are not equal. One of the two goes complex from about gama = pi to gama = 17*pi/16 . From 17*pi/16 to roughly 48*Pi/41 the difference between the two is real valued . After that the difference has a real component of 2*pi and an increasing imaginary component.

8 Comments

safi58
safi58 on 22 Apr 2017
Edited: safi58 on 22 Apr 2017
Thanks all.
I substituted M=0.96 and l=0.218 (l is fixed)and gama is pi or less then these two expressions give same results. But I could not transform the first one into second.
The two are only the same in the range -pi to +pi, exclusive (there is a discontinuity at -pi and +pi)
I have tried simplifying the expression with this assumption, but still no dice.
The rewrite is not clear.
How did you get to know that the two were the same? How was the first one produced? It might be easier to find a different way of producing the expression.
syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1
syms m_c_theta1 gama l s
eqn1 = m_c_theta1==(m_c0-1/M-1)*cos(theta1)+j_L0*sin(theta1)+1/M+1;
eqn2 = j_L_theta1==(-m_c0+1/M+1)*sin(theta1)+j_L0*cos(theta1);
eqn3 = m_c_gama==(m_c_theta1-1/M+1)*cos(gama-theta1)+j_L_theta1*sin(gama-theta1)+1/M-1;
eqn4 = j_L_gama==(-m_c_theta1+1/M-1)*sin(gama-theta1)+j_L_theta1*cos(gama-theta1);
m_c_gama=-m_c0;
j_L_gama=-j_L0;
j_L_theta1=-(gama*l)/2;
eqns = subs([eqn1, eqn2, eqn3, eqn4]);
sol = solve(eqns, m_c0, j_L0,theta1,m_c_theta1)
This is the code I have used to find the solution for a as theta1 and other is the solution from an article and from that I know that those are same.
I copied the code, except changing to
sol = solve(eqns, m_c0, j_L0,theta1,m_c_theta1, 'returnconditions', true);
MATLAB thinks about it quite a while, and eventually says it cannot find a solution.
Yes, without the return condition, it gives the solution.
To summarize what Walter and I are saying, the two expressions are clearly not always equal, and the conditions under which they are equal are hard to pin down. Perhaps you should look more closely at how they did it in the article. Not that published work is always 100% correct.

Sign in to comment.

Asked:

on 18 Apr 2017

Commented:

on 23 Apr 2017

Community Treasure Hunt

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

Start Hunting!