intel MCS BASIC-52 — Intel MCS BASIC-52 Versions 1 & 1.1 Operating and Reference Manual PDF (EN)

int e l 5.2.3 UNARY OPERATORS -- TRIG FUNCTIONS TAN([expr]) Returns the TAN of the argument. The argument is expressed in radians. The argument must be between +- 200000. EXAMPLES: PRINT TAN(PI/4) PRINT TAN(0) 1 0 ATN([expr]) Returns the ARCTANGENT of the argument. The result is in radians. Calculations are carried out to 7 significant digits. The ATN operator returns a result between -PI/2 (3.1415926/2) and PI/2. EXAMPLES: PRINT ATN(PI) PRINT ATN(1) 1.2626272 .78539804 COMMENTS ON TRIG FUNCTIONS The SIN, COS, and TAN operators use a Taylor series to calculate the function. These operators first reduce the argument to a value that is between 0 and PI/2.

This reduction is accomplished by the following equation: REDUCED ARGUMENT = (user arg/PI - INT(user arg/PI)) * PI The REDUCED ARGUMENT, from the above equation, will be between 0 and PI. The REDUCED ARGUMENT is then tested to see if it is greater than PI/2. If it is, then it is subtracted from PI to yield the final value. If it isn't, then the REDUCED ARGUMENT is the final value. Although this method of angle reduction provides a simple and economical means of generating the appropriate arguments for a Taylor series. there is an accuracy problem associated with this technique. The accuracy problem is noticed when the user argument is large (i.e. greater than 1000).

That is because significant digits, in the decimal (fraction) portion of REDUCED ARGUMENT are lost in the (user arg/PI - INT(user arg/PI)) expression. As a general rule, try to keep the arguments for the TRIG functions as small as possible! - 79 -