[cfp-interest 3431] Range error conditions for atan2 and atan2pi

Javier Múgica javier at aerotri.es
Sun Apr 13 10:09:38 PDT 2025


I have come across the condition for domain error and range error for several functions, and I bring to points to your attention:

--------- 1st

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.

The last sentence reads, in English, "A range error occurs if (x is (positive and nonzero) y/x is too close to zero)."

and there seems to be a missing "and". But reading the analogous sentence for other functions, e.g., atan:

The atan functions compute the principal value of the arc tangent of x. A range error occurs if nonzero x is too close to zero.

one can guess the intended meaning. It should read:

A range error occurs if x is positive and if y/x is nonzero and too close to zero.

--------- 2nd

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.
This distinction is present in exponential functions, but there it makes sense.


Regards,

Javier Múgica



More information about the cfp-interest mailing list