[R] calculating error
Deepayan Sarkar
deepayan at stat.wisc.edu
Sun Sep 12 20:42:48 CEST 2004
On Sunday 12 September 2004 13:28, Branimir K. Hackenberger wrote:
> Could anybody explain this results?
>
> >sin(2*pi)
>
> -2.449213e-16 #should be zero
It is, in the sense that
> all.equal(sin(2*pi), 0)
[1] TRUE
> >(10^16)*sin(log2(4)*pi)
>
> -2.449213 #should be zero too
>
>
> and explain what to do to correct this events?
For starters, you need to invent and then use an infinite precision
computer where the variable 'pi' is really the ratio between the
circumference and radius of a circle, and not just a finite precision
approximation of it. Good luck trying :-)
Deepayan
More information about the R-help
mailing list