Skip to content

nthroot

Real n-th root of an array.

Y = nthroot(X, n)

Returns the real n-th root of each element of X. n must be a positive integer scalar. For odd n, negative inputs return real negative results; for even n, negative inputs raise a complex domain warning (or return NaN depending on element type). Equivalent to X.^(1/n) for positive X.

nthroot(27, 3) % 3
nthroot(-8, 3) % -2 (cube root of -8)
nthroot([1 8 27], 3) % [1 2 3]
  • floor — Round toward negative infinity.
  • round — Round to the nearest integer (or to a specified number of digits).