sin() function in IDL 4.0.1 [message #5773] |
Mon, 12 February 1996 00:00  |
Miska Le Louarn
Messages: 8 Registered: December 1995
|
Junior Member |
|
|
Hello,
I just found an interesting behaviour of the sine function:
when I ask IDL (4.0.1) to calculate sin(pi) here is what I get:
IDL> print,sin(!Dpi)
1.2246064e-16 ; This should be 0.0000... (?)
On the other hand, sin(0) works fine:
IDL> print,sin(0D0)
0.0000000 ; This seams to be a "real" 0
I also tested cos(!Dpi):
IDL> print,cos(!Dpi)
-1.0000000
and cos(0D0):
IDL> print,cos(0D0)
1.0000000
Another different behaviour is:
IDL> print,cos(!Dpi/2D0)
6.1230318e-17
So my question is: why are there two different kind of zeroes ? is it a
bug ? a "feature" ? or maybe simply a format question (the result is
sometimes rounded...)
I know that there can be round-off errors and things like that, so
I am not surprised by the answer itself but rather by the difference
between within what should be the same...
Has anyone a good explanation for that ?
Thanks
Miska
--
* Miska Le Louarn Phone: (49) (89) 32006472 *
* ESO - European Southern Observatory FAX : (49) (89) 3202362 *
* Karl-Schwarzschild Strasse 2 e-mail: lelouarn@eso.org *
* D-85748 Garching bei Munchen *
* Federal Republic of Germany *
|
|
|