symbolic trigonometrical function tan instead of log and imaginary equation
5 views (last 30 days)
Show older comments
I have this simple code
syms a b x real;
solve(a*sin(x) == b*cos(x),x)
%the answer should looks like x= -atan(b/a)
%I got
-log((a^2 + b^2)^(1/2)/(a - b*1i))*1i
-log(-(a^2 + b^2)^(1/2)/(a - b*1i))*1i
is there a way to avoid complex and log and just make it simple trigonometrical function?
2 Comments
Dyuman Joshi
on 17 Mar 2023
Walter, rewrite() does convert the solution in terms of atan but it still contains complex values
syms a b x real
%assumptions
sol=solve(a*sin(x) == b*cos(x),x)
rewrite(sol,"atan")
Answers (1)
Dyuman Joshi
on 17 Mar 2023
Edited: Dyuman Joshi
on 17 Mar 2023
syms a b x real
sol1=solve(a*sin(x) == b*cos(x),x,'Real',true)
The solution obtained above can be derived by changing sin and cos to half angle terms, dividing the equation by (cos (x/2))^2 thus converting the equation into a quadratic equation in tan(x/2) and solving it.
Though I do not know why this particular solution is obtained as the output instead of atan(b/a).
To obtain a general solution and conditions on the solution.
sol2=solve(a*sin(x) == b*cos(x),x,'Real',true, 'ReturnConditions', true)
sol2.x
sol2.conditions
0 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!