How do we find the Nth root in R?
4^2 = sqrt(16)
But what is the code snippet for the opposite transformation of;
4^7 = ???
How do we find the Nth root in R?
4^2 = sqrt(16)
But what is the code snippet for the opposite transformation of;
4^7 = ???
Simple
sqrt(4) == 4^(1/2)
# 7th root of 4
4^(1/7)
In calculus, roots are treated as special cases of exponentiation, where the exponent is a fraction:
https://en.wikipedia.org/wiki/Nth_root#Definition_and_notation
You should probably NOT use x^(1/n). It works perfectly well with nonnegative numbers, but if you tried
(-4)^(1/7)
you would get NaN
. A better way is with nthroot
.
> library(pracma)
> nthroot(-4, 7)
[1] 1.219