Bad Math Module Notation re: atan2

Ben Caradoc-Davies bmcd at es.co.nz
Fri Jun 2 19:11:08 EDT 2000


On Thu, 01 Jun 2000 14:59:57 -0400, Lou Pecora <pecora at anvil.nrl.navy.mil> 
wrote:
>Maybe you've all kicked this around before, but I've just picked up
>Python in the last month or so.  The notation for atan2(x,y) is 
> atan2(x,y)= arctangent( x/y)
>Given the usual association of x with the abscissa and y with the
>ordinate in mathematics, science and engineering it is easy to mistake
>atan2(x,y) as arctangent (y/x) (x and y reversed!).  Or in another
>view, according to the majority of mathematically trained people
>atan2(x,y) as defined appears to deliver the arccotangent.  
>Am I mising something?

The math module implementation gives:
1) Consistency with the C standard library (see K&R2 p251).
2) Consistency with the order you write it;
   I write the following

             y
       atan  -
             x

   by writing atan, then y, then x,
   which in Python is atan2(y,x) (for the four quadrant atan).

As other have pointed out, don't be confused by the misleading x<->y
notation change in the math module documentation. The math module does
The Right Thing(tm), particularly for the reason given in (1) above.

-- 
Ben Caradoc-Davies <bmcd at es.co.nz>



More information about the Python-list mailing list