[cfp-interest 3462] Re: Range error conditions for atan2 and atan2pi

Paul Zimmermann Paul.Zimmermann at inria.fr
Thu May 15 00:51:22 PDT 2025


       Hi,

> atan2:
> 
> The atan2 functions [...]. A domain error may occur if both arguments are
> zero. A range error occurs if x is positive and nonzero y/x is too close to
> zero.
>
> Why "positive"? Considering that atan2 is an odd function, +x and -x should
> give +alpha and -alpha uniformly. The "atan", "sin", "tan", etc. functions
> don't make this distinction. Its presence in atan2 and atan2pi seems
> spurious.

for y/x close to zero and x > 0, atan2(y,x) is close to zero, since z = x+i*y
is near the right real axis, and atan2(y,x) gives the angle of the complex
number z.

However, for y/x close to zero and x < 0, the complex number z is close to the
left real axis, and then atan2(y,x) is close to +/-pi according to the sign of
y. In that case there can be no underflow, thus no domain error.

Thus the current text is fine.

Paul


More information about the cfp-interest mailing list