[R] Trig functions strange results

Nair, Murlidharan T mnair at iusb.edu
Tue Jul 14 19:45:23 CEST 2009


I am trying to calculate coordinate transformations and in the process of debugging my code using debug I found the following

Browse[1]> direction[i]
[1] -1.570796
Browse[1]> cos(direction[i])
[1] 6.123032e-17
Browse[1]> cos(-1.570796)
[1] 3.267949e-07
Browse[1]> direction[i]
[1] -1.570796
Browse[1]> cos(direction[i])
[1] 6.123032e-17
Browse[1]> cos(-1.570796)
[1] 3.267949e-07
Browse[1]> x<-direction[i]
Browse[1]> x
[1] -1.570796
Browse[1]> cos(x)
[1] 6.123032e-17

I am not sure why I am getting one values when I am using a variable that stores the value and another when I use the value directly.  Am I missing something here? 

Can someone comment?

Thanks ../Murli




More information about the R-help mailing list