[Numpy-discussion] what goes wrong with cos(), sin()

Christopher Barker Chris.Barker at noaa.gov
Wed Feb 21 14:54:14 EST 2007


Anne Archibald wrote:
> Or, to see more clearly, try taking (on a pocket calculator, say)
> sin(3.14) (or even sin(pi)).

This is an interesting point. I took a class from William Kahan once 
(pass/fail, thank god!), and one question he posed to us was:

How many digits of pi is used in an HP calculator?

I never figured out the answer myself, and the question involved the 
info that certain calculations involving pi being accurate to a certain 
degree. I don't have my HP calculator with me right now but I suspect 
that sin(pi) might well evaluate to exactly zero, or closer than 1e-16 
anyway.

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)

-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 at noaa.gov



More information about the NumPy-Discussion mailing list