symbolic trigonometrical function tan instead of log and imaginary equation
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Dyuman Joshi
il 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")
Risposte (1)
Dyuman Joshi
il 17 Mar 2023
Modificato: Dyuman Joshi
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!