Why is tan(a) not equal to sin(a)/cos(a)
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
trying to simplify sin(alpha)/cos(alpha) Matlab does not give tan(alpha), why?
also isolating alpha from b == sin(alpha)/cos(alpha) does not give alpha = atan(b), why?
>> syms alpha b
equ1=b==sin(alpha)/cos(alpha)
simplify(equ1)
equ1=isolate(equ1,alpha)
equ1 =
b == sin(alpha)/cos(alpha)
ans =
b == sin(alpha)/cos(alpha)
equ1 =
alpha == -log((- b^2 - 1)^(1/2)/(b + 1i))*1i
1 Commento
David Goodmanson
il 24 Apr 2022
Modificato: David Goodmanson
il 24 Apr 2022
Hi cpistor,
to be honest, there are certain situations where Matlab symbolics is not all that bright. But the expression for alpha on your last line is a good expression for atan(b).
( For complex input, the expression does not always exactly agree with atan. Somtimes there is disagreement by pi, reflecting the pi ambiguity in the tan function, i.e. tan(theta) = tan(theta +-pi) )
Risposte (1)
Paul
il 25 Apr 2022
It's kind of a pain, but ....
syms b alpha
eq1 = b == sin(alpha)/cos(alpha);
eq1 = rewrite(eq1,'tan')
eq1 = lhs(eq1) == simplify(rhs(eq1))
alpha_sol = solve(eq1,alpha)
Actually, I'm kind of surprised the SMT yileds this result w/o some further assumptions on the range of alpha. Suppose alpha = 3*pi/4.
syms b alpha
alpha = 3*sym(pi)/4;
b = sin(alpha)/cos(alpha);
atan(b)
OTOH, if we solve() eq1 w/o the simplifications, we get
syms b alpha
eq1 = b == sin(alpha)/cos(alpha);
alpha_sol = solve(eq1,alpha,'Real',true,'ReturnConditions',true);
alpha_sol.alpha
alpha_sol.conditions
I think those solutions are basically atan(b) and atan(b) +- pi.
0 Commenti
Vedere anche
Categorie
Scopri di più su Assumptions 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!