[R] sin(pi)?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Sep 3 09:01:06 CEST 2007


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 just seeing zero at two 
different levels of precision.

The built-in pi has more digits than it displays:

 > pi
[1] 3.141593
 > pi - 3.141593
[1] -3.464102e-07
 > print(pi, digits=20)
[1] 3.141592653589793

> ____________________________
> Nguyen Dinh Nguyen
> Garvan Institute of Medical Research
> Sydney, Australia
>
>   
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list