[cfp-interest 3434] Re: Range error conditions for atan2 and atan2pi
Paul Zimmermann
Paul.Zimmermann at inria.fr
Sun Apr 13 22:48:25 PDT 2025
Dear Javier,
> From: "Javier Múgica" <javier at aerotri.es>
> Date: Sun, 13 Apr 2025 19:09:38 +0200 (CEST)
>
> 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.
I agree with this.
> --------- 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.
atan2(y,x) gives the argument of the complex number x+i*y.
For y/x near 0 and x negative, the argument is near +/-pi, thus there is
no underflow.
Paul
More information about the cfp-interest
mailing list