Error of tan/tanf in libm.

Stephen L Moshier
Mon Apr 16 18:46:00 GMT 2001

On Mon, 16 Apr 2001, J. Johnston wrote:
> Thanks for the patch Stephen.

I should have pointed out why the change accomplishes anything.
If you look at this code near the end of the program,

      p = 2.0 * s * r - (pio2_lo - 2.0 * c);
      q = pio4_hi - 2.0 * w;
      t = pio4_hi - (p - q);

you see that pio2_lo plus twice pio4_hi is supposed to equal pi/2
to extra precision.  But also pio2_lo plus pio2_hi is supposed
to be the same thing.  Therefore pio4_hi must be exactly half
of pio2_hi, which was not the case.

More information about the Newlib mailing list