in BASIC ROM:
|List of all BASIC keywords|
Type: Numeric Function
The numerical function TAN is a mathematical function which evaluates to the tangent for a given angle, a number regarded as being in radians.
If the term given in the parentheses is non-numerical, the BASIC error ?TYPE MISMATCH ERROR occurs. Being a floating point argument, the term must be in the range of ±2.93873588·10−38 to ±1.70141183·1038. Exceeding these limits yields the BASIC error ?OVERFLOW ERROR. Special values like +/-π/2 (+/- 90 degree) according to the definition of the function lead to the BASIC error ?DIVISION BY ZERO. Omitting the numeric argument or to many arguments results in a ?SYNTAX ERROR.
Accuracy[edit | edit source]
The graph to the right was obtained by comparing results from the BASIC TAN function to values computed on a modern x86-type PC.
For most inputs, TAN is accurate to about 29 bits. Values for which SIN and COS lose accuracy also lose accuracy for TAN. The accuracy close to X = 0 could be improved by patching SIN to return SIN(X) = X for |X| less than 2-11.
Implementation details[edit | edit source]
TAN(X) is implemented simply as SIN(X)/COS(X).
Examples[edit | edit source]
Defines the function of cotangent (tangent complement) as user defined function FN CT(), called with an angle of 45°.
Provokes the error ?DIVISION BY ZERO ERROR for an argument representing the angle of 90°.
On screen the value -7.3145904E-10 will be shown, a very small value near to 0 (also for all multiples of π), but not exactly reached caused by the inaccuratness of the internal implementation of the function.