[R] sin(pi)?

2007-09-03 Thread Nguyen Dinh Nguyen
Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be appreciated. Regards Nguyen Nguyen Dinh Nguyen Garvan Institute of Medical Research

Re: [R] sin(pi)?

2007-09-03 Thread Olivier Delaigue *
sin(3.141592653589793) [1] 1.224606e-16 Regards, Olivier Delaigue Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be

Re: [R] sin(pi)?

2007-09-03 Thread Peter Dalgaard
Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value sin(pi) [1] 1.224606e-16 pi [1] 3.141593 sin(3.141593) [1] -3.464102e-07 Any help and comment should be appreciated. Regards Nguyen Well, sin(pi) is theoretically zero, so you are

Re: [R] sin(pi)?

2007-09-03 Thread Simon Blomberg
Umm. pi has been rounded to 6 decimal places in the second example. So it isn't surprising that the results differ. sin(pi) is not zero, as it also has been rounded, and you can't represent irrational numbers exactly in a numerical form anyway. R agrees with Octave: octave:1 sin(pi) ans =

Re: [R] sin(pi)?

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Nguyen Dinh Nguyen wrote: Dear all, I found something strange when calculating sin of pi value What exactly? Comments below on two guesses as to what. sin(pi) [1] 1.224606e-16 That is non-zero due to using finite-precision arithmetic. The number stored as pi is not