Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

### ATN

 Keyword Abbreviation Token (hex) Version(s) Classification ATN A{Shift+T} C1 1.0+ Function

ATN slope )

 Parameters Type Legal Value(s) Note(s) slope Numeric any

 Returns Type Value(s) Note(s) angle Floating-point -1.57079633 to +1.57079633 the angle is in radians

 Purpose
Calculate an angle which has the given slope.

 Remarks
The ATN function calculates an angle (measured in radians) with the given slope.  The slope can be described in a few (equivalant) ways: as the ratio of "rise" over "run", or dy / dx, or the "trignometric tangent" (not to be confused with a geometric tangent).  If the slope is omitted or not a valid expression, SYNTAX ERROR is generated.  If slope is not numeric, a TYPE MISMATCH ERROR occurs.

The returned angle is in radians; it may converted to degrees by multiplying it by 180 / pi (i.e., multiply the result by about 57.2958).  The returned angle, measured in degrees, will range from -90 to +90 (the radian range is shown in the table above).  This is only a span of half a circle (180 degees).  To determine an angle anywhere in the span of a full sircle (range of 360 degrees), additional information is required: you need to know the sign of dx.  If dx ("run") is positive, then you can use the angle as-is.  Otherwise, add pi radians (180 degrees) to the returned angle.

Besides use in triginometry (directly) it may also be useful in other fields of engineering and science, in particular for calculating the "phase angle" of a complex number (very similar to the conversion from rectangular to polar coordinates).

ATN is the priciple inverse of the TAN function.

Examples:
 ```PRINT ATN(0) 0 READY. PRINT ATN(1) .785398163 READY. PRINT ATN(1000) 1.56979633 READY. ```

 Compare With

 Contrast With