[Numpy-discussion] what goes wrong with cos(), sin()
Christopher Barker
Chris.Barker@noaa....
Wed Feb 21 14:27:56 CST 2007
Robert Kern wrote:
> Christopher Barker wrote:
>> I wonder if there are any C math libs that do a better job than you'd
>> expect from standard FP? (short of unlimited precision ones)
>
> With respect to π and the zeros of sin() and cos()? Not really. If
> numpy.sin(numpy.pi) were to give you 0.0, it would be *wrong*. numpy.sin() is
> supposed to give you the most accurate result representable in double-precision
> for the input you gave it.
But does it?
> numpy.pi is not π.
More precisely, it's the best IEEE754 64 bit FP approximation of pi.
Right. I think that was the trick that HP used -- they somehow stored
and worked with pi with more digits. The things you can do if you're
making dedicated hardware.
I do wonder if there would be some way to use the extended precision
built in to Intel FP hardware -- i.e. have a pi that you can pass in
that has the full 80 bits that can be used internally. I don't know if
the trig functions can be done with extended precision though.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the Numpy-discussion
mailing list