PRB: tan(pi/2) Returns Value, Causes No ErrorLast reviewed: July 25, 1997Article ID: Q11158 |
The information in this article applies to:
SYMPTOMSIf an application uses the tan() run-time function to compute the value of pi/2, the function returns a value. Mathematically, this value is not defined.
CAUSEThis error is caused by the precision with which numbers can be represented in the computer. It is not possible to specify a value X close enough to the true value of pi/2 to cause tan(X) to overflow.
MORE INFORMATIONThe tangent of a value is defined as the sine of the value divided by the cosine of the value. Therefore, the tangent of pi/2 is the sine of pi/2 (1) divided by the cosine of pi/2 (0). Because the cosine of pi/2 is 0, its tangent is undefined.
sin(pi/2) 1 tan(pi/2) = ----------- = --- = undefined, divide by zero cos(pi/2) 0The function tan(pi/2) returns a value because the computer approximates pi to a limited number of digits. Even at double precision, the approximate value of pi is not large enough to cause cos(pi/2) to equal zero. Therefore, tan(pi/2) returns an unexpected value, as follows:
Approximate pi = 3.1415926535 sin(pi/2) sin(3.1415926535/2) 1 tan(pi/2) = ----------- = ------------------- = ----------------- cos(pi/2) cos(3.1415926535/2) 0.000000000044896 Keywords : CRTIss kbfasttip Version : 5.1 6.0 6.0a 6.0ax 7.0 1.0 1.5 2 Platform : MS-DOS NT OS/2 WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |