Re: Accuracy of tan()?

From: Gerry Thomas (gfthomas_at_sympatico.ca)
Date: 06/29/04


Date: Tue, 29 Jun 2004 02:26:42 -0400


"Everett M. Greene" <mojaveg@iwvisp.com> wrote in message
news:20040623.7A1BB70.A513@mojaveg.iwvisp.com...
> We have a situation where we have a tan() function
> implemented in single-precision floating point
> arithmetic and a test case is tan(-1.570796). We
> are getting results of
>
> - 3060018.
> - 3185560.75
> - 3185560.708
> - 3560236.5
> - 5340352.5
> -37320540.2
>
> depending on the implementation.
>
> How does one define the accuracy of the tangent function
> near the odd multiples of pi/2 and which of the above is
> the "better" result?
>
> As far as I'm concerned, any big number is good enough
> in the vicinity of odd multiples of pi/2 since one
> has an ill-formed problem if using tan() in these regions.

FYI, 6381956970095103 x 2**797 = 5.319372648326541416707296656674d+255 is
the
closest double to pi/2 in the range [tiny(0.d0), huge(0.d0)].

In Randal Hyde's 'Art of Assembly Language' book he remarks that for /arg/
<=2^63 ~10^19, the trigs are evaluated as usual ~1ulp. Beyond that, how arg
reduction has been implemented (if at all) has a significant bearing on the
quality of the outcome, but more than a few on CLF were of the 'so what' or
the 'user as idiot' strawmanning persuasion. So don't buy into the myth
that Fortran users care more about the validity of numerical results than
anyone else, it just ain't necessarily so.

-- 
You're Welcome,
Gerry T.
______
"In a world in which the price of calculation continues to decrease
rapidly, but the price of theorem proving continues to hold steady or
increase, elementary economics indicates that we ought to spend a larger
and larger fraction of our time on calculation." -- J.W. Tukey.


Relevant Pages

  • Re: Accuracy of tan()?
    ... > near the odd multiples of pi/2 and which of the above is ... > has an ill-formed problem if using tan() in these regions. ... "In a world in which the price of calculation continues to decrease ...
    (sci.math.num-analysis)
  • Re: Accuracy of tan()?
    ... > implemented in single-precision floating point ... > near the odd multiples of pi/2 and which of the above is ... > has an ill-formed problem if using tan() in these regions. ...
    (sci.math.num-analysis)
  • Accuracy of tan()?
    ... implemented in single-precision floating point ... near the odd multiples of pi/2 and which of the above is ... has an ill-formed problem if using tan() in these regions. ...
    (sci.math.num-analysis)