Nair, Murlidharan T wrote:
> 
> 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? 
> 
> 

Because you are not looking at the full precision of the data.  Try
print(x,digits=20) ...

  Ben Bolker
-- 
View this message in context: 
http://www.nabble.com/Trig-functions-strange-results-tp24484518p24485352.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

Reply via email to