Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nthroot

Real nth Root


Description

Compute the real n-th root of real numbers.

Usage

nthroot(x, n)

Arguments

x

numeric vector or matrix

n

positive integer specifying the exponent 1/n.

Details

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)

Value

Returns a numeric vector of solutions to x^{1/n}.

See Also

Examples

nthroot(c(1, -2, 3), 3)  #=> 1.000000 -1.259921  1.442250
  (-2)^(1/3)               #=> NaN

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.