Why is tan(a) not equal to sin(a)/cos(a)

조회 수: 33 (최근 30일)
cpistor
cpistor 2022년 4월 24일
답변: Paul 2022년 4월 25일
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
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
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 = 
eq1 = lhs(eq1) == simplify(rhs(eq1))
eq1 = 
alpha_sol = solve(eq1,alpha)
alpha_sol = 
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)
ans = 
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
ans = 
alpha_sol.conditions
ans = 
I think those solutions are basically atan(b) and atan(b) +- pi.

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by