[PATCH v2 20/25] math: Use atanf from CORE-MATH
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Wed Dec 18 13:48:38 GMT 2024
On 10/12/24 05:47, Paul Zimmermann wrote:
> Hi DJ,
>
>> One question about the tail and of sysdeps/ieee754/flt-32/s_atanf.c wrt copysign
>
> let me answer that question
>
>>> + /* now |x| >= 1 */
>>> + r = copysign (0x1.0fdaa22168c23p-7, z) - r + copysign (0x1.9p0, z);
>>
>> This seems odd; there's no reason to have two copysign's - they could be
>> combines into "copysign(...) - r". Unless there's rounding issues, in
>> which case, a comment and parens are warranted to force operation order
>> despite optimizations.
>
> here r approximates atan(1/x), and we use atan(x) + atan(1/x) = sign(x)*pi/2.
>
> Let H=0x1.9p0 and L=0x1.0fdaa22168c23p-7, where H+L approximates pi/2.
>
> If you write sign(z)*L + (-r + sign(z)*H), it fails for x=0x1.98c252p+12 and
> rounding upward.
>
> If you write sign(z)*PI - r, where PI is a double approximation of pi to
> nearest, it fails for x=0x1.ddf9f6p+0 and rounding upward.
>
> Thus indeed we have to write (sign(z)*L + -r) + sign(z)*H, unless you find a
> more clever way. I'll add comments upstream.
>
> Paul
I will update the patch with CORE-MATH commit a8066a5c8f7845a2f873b624104cf802f7e4e45c,
thanks Paul.
More information about the Libc-alpha
mailing list