Version 1 of atan

Updated 2001-12-15 11:30:29

Purpose: Explain the math function atan.


The call,

    [expr { atan( $x ) }]

returns the inverse tangent of the number, $x. The resulting angle is measured in radians.


Most uses of atan are perilous. The problem is that there is always uncertainty about the quadrant of the angle:

 % set PI 3.1415926535897932
 3.1415926535897932
 % puts [expr {tan ( 0.25 * $PI ) }]
 0.99999999999999989
 % puts [expr { tan ( 1.25 * $PI ) }]
 0.99999999999999967

In other words, when you say,

    [expr { atan( 1.0 ) }]

it is hard to know whether you mean

 0.25 * $PI

or

 1.25 * $PI

For this reason, atan should generally be avoided in favor of atan2, which does not suffer from this problem.


Math function help - Arts and crafts of Tcl-Tk programming - Category Mathematics