abs()
function computes the absolute value of x, while sqrt()
functions computes the square root of x. the only parameter for these functions is x
, which is the value to compute.abs(10)
## [1] 10
abs(-10)
## [1] 10
sqrt(10)
## [1] 3.162278
sqrt(-10)
## Warning in sqrt(-10): NaNs produced
## [1] NaN
sqrt(abs(-10))
## [1] 3.162278
plot(15:-15, sqrt(abs(15:-15)), col = "orange")
lines(spline(15:-15, sqrt(abs(15:-15))), col = "gold")