nthroot | R Documentation |
Compute the real n-th root of real numbers.
nthroot(x, n)
x |
numeric vector or matrix |
n |
positive integer specifying the exponent |
Computes the n-th root real numbers of a numeric vector x
,
while x^(1/n)
will return NaN
for negative numbers,
even in case n
is odd. If some numbers in x
are negative,
n
must be odd. (This is different in Octave)
Returns a numeric vector of solutions to x^{1/n}
.
sqrt
nthroot(c(1, -2, 3), 3) #=> 1.000000 -1.259921 1.442250
(-2)^(1/3) #=> NaN
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.