abs() function computes the absolute value of x, while sqrt() function computes the square root of x.
The parameters of the functions are:
x: numeric vector or arrayabs(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")

No comments:
Post a Comment