Why the trigonometry results are different
조회 수: 10 (최근 30일)
이전 댓글 표시
Why there is a difference in the results. in degrees it is showing inf and in radians a different result?
>> a=tan(90)
a =
-1.9952
>> b=tand(90)
b =
Inf
>> c=tan(pi/2)
c =
1.6331e+16
댓글 수: 0
채택된 답변
Peter Perkins
2014년 8월 22일
1.6331e+16 is the right answer. Remember that pi/ is irrational. There is no way to represent it in double precision. The tangent of the double precision value pi/2 evaluates to is 1.6331e+16. That's the main reason for the existence of tand -- 90 is exact.
댓글 수: 0
추가 답변 (3개)
David Sanchez
2014년 8월 21일
The different result between tan(90) and tan(pi/2) is obvious.
1.6331e+16 might be considered equal to inf
댓글 수: 0
Iain
2014년 8월 21일
That's likely just the effect of small numerical errors.
After all, according to matlab,
1E300 + 1 - 1E300 = 0, and
1E300 - 1E300 + 1 = 1
댓글 수: 0
Adam
2014년 8월 21일
tan is asymptotic at 90 degrees, but pi/2 will not evaluate to the precise equivalent with a numerical estimate of pi so its result will not be precisely on the asymptote
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!