Why is tan(a) not equal to sin(a)/cos(a)
조회 수: 33 (최근 30일)
이전 댓글 표시
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
David Goodmanson
2022년 4월 24일
편집: David Goodmanson
2022년 4월 24일
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) )
답변 (1개)
Paul
2022년 4월 25일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!