https://github.com/cran/pracma
Raw File
Tip revision: 708a2ad382a163d1eef5af0665e3ae2aad200ced authored by HwB on 21 March 2013, 00:00:00 UTC
version 1.4.5
Tip revision: 708a2ad
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