https://github.com/cran/pracma
Raw File
Tip revision: c79a04b5074656b36e591191eb8137b70a349932 authored by Hans W. Borchers on 30 June 2014, 00:00:00 UTC
version 1.7.0
Tip revision: c79a04b
nthroot.Rd
\name{nthroot}
\alias{nthroot}
\title{Real nth Root}
\description{
  Compute the real n-th root of real numbers.
}
\usage{
  nthroot(x, n)
}
\arguments{
  \item{x}{numeric vector or matrix}
  \item{n}{positive integer specifying the exponent \eqn{1/n}.}
}
\details{
  Computes the n-th root real numbers of a numeric vector \code{x},
  while \code{x^(1/n)} will return \code{NaN} for negative numbers,
  even in case \code{n} is odd. If some numbers in \code{x} are negative,
  \code{n} must be odd. (This is different in \emph{Octave})
}
\value{
  Returns a numeric vector of solutions to \eqn{x^{1/n}}.
}
\seealso{
  \code{\link{sqrt}}
}
\examples{
  nthroot(c(1, -2, 3), 3)  #=> 1.000000 -1.259921  1.442250
  (-2)^(1/3)               #=> NaN
}
\keyword{ arith }
back to top