I have tried measuring the speed of these two ways for taking square root:
> system.time(expr = replicate(10000, 1:10000 ** (1/2)))
## user system elapsed
## 0.027 0.001 0.028
> system.time(expr = replicate(10000, sqrt(1:10000)))
## user system elapsed
## 3.722 0.665 4.494
If the sqrt()
function cannot compete with ** 0.5
, why do we need such a function?
(system is OS X Yusemite, and R version is 3.1.2)