I have an issue where there is a difference in the results when I use sqrt(x) rather than x^0.5.
The calculations are being carried out on floating point numbers such as:
0.002296438
Trouble is this truncated version as displayed in Rstudio does not replicate the problem. However the non-truncated version does (any idea how I can get the non-truncated version to display so I can show a working example)?
The errors are indeed small of the order of e^-18 which are not so worrying in themselves. However over even moderately large data sets (10,000 date points) these errors compound to give errors in the variance estimate at the 4th decimal place which is more concerning!
I realize that R is only accurate to 16 decimal places, see answer from nullglob below but these errors seems to be systematic? Every time you run sqrt(x) and x^0.5 they both produce the same answer each time. However these answers are still different from each other.
Formatting Decimal places in R
Is one version considered to be more accurate than the other?
Baz
OK here is the example
[1] 0.002296437934635199226707
> test4=sqrt(0.002296437934635199226707)
> test5=0.002296437934635199226707^0.5
> test6=test5-test4
test6
[1] 6.938894e-18