# TAN

 BASIC keyword Keyword: TAN Abbreviation: – Type: Function Token code: 192/\$C0 Handling routinein BASIC ROM: 58036–58079\$E2B4–E2DF List of all BASIC keywords

Remark: This article describes the BASIC-Command TAN in BASIC V2 at the Commodore 64.

 Type: Numeric Function General Programming-Syntax: TAN()

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.

## Implementation details

TAN(X) is implemented simply as SIN(X)/COS(X).

## Examples

```PRINT TAN(1)
```

Output: 1.55740772

```10 DEF FN CT(X) = 1/TAN(X)
20 PRINT FN CT(45*π/180)
```

Defines the function of cotangent (tangent complement) as user defined function FN CT(), called with an angle of 45°.

```PRINT TAN(π/2)
```

Provokes the error ?DIVISION BY ZERO ERROR for an argument representing the angle of 90°.

```PRINT TAN(π)
```

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.

BASIC V2.0 (second release) Commands

ABS | AND | ASC | ATN | CHR\$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT\$ | LEN | LET | LIST | LOAD | LOG | MID\$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT\$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR\$ | SYS | TAB | TAN | THEN | TIME/TI | TIME\$/TI\$ | TO | USR | VAL | VERIFY | WAIT