The R Project SVN R

Rev

Rev 68948 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/Math.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
61129 maechler 3
% Copyright 1995-2012 R Core Team
4
% Copyright 2002-2012 The R Foundation
42333 ripley 5
% Distributed under GPL 2 or later
6
 
46963 ripley 7
\name{MathFun}
2 r 8
\title{Miscellaneous Mathematical Functions}
9
\usage{
10
abs(x)
11
sqrt(x)
12
}
13
\alias{abs}
14
\alias{sqrt}
15
\description{
61129 maechler 16
  \code{abs(x)} computes the absolute value of x, \code{sqrt(x)} computes the
17
  (principal) square root of x, \eqn{\sqrt{x}}.% Details for complex x are below
18
 
19
  The naming follows the standard for computer languages such as C or Fortran.
2 r 20
}
15518 ripley 21
\arguments{
28651 maechler 22
  \item{x}{a numeric or \code{\link{complex}} vector or array.}
15518 ripley 23
}
27273 ripley 24
\details{
51317 ripley 25
  These are \link{internal generic} \link{primitive} functions: methods
26
  can be defined for them individually or via the
27
  \code{\link[=S3groupGeneric]{Math}} group generic.  For complex
28
  arguments (and the default method), \code{z}, \code{abs(z) ==
29
  \link{Mod}(z)} and \code{sqrt(z) == z^0.5}.
40200 maechler 30
 
31
  \code{abs(x)} returns an \code{\link{integer}} vector when \code{x} is
32
  \code{integer} or \code{\link{logical}}.
27273 ripley 33
}
41393 ripley 34
\section{S4 methods}{
35
  Both are S4 generic and members of the
49567 ripley 36
  \code{\link[=S4groupGeneric]{Math}} group generic.
41393 ripley 37
}
2 r 38
\seealso{
28651 maechler 39
  \code{\link{Arithmetic}} for simple, \code{\link{log}} for logarithmic,
40
  \code{\link{sin}} for trigonometric, and \code{\link{Special}} for
41
  special mathematical functions.
43114 ripley 42
 
43
  \sQuote{\link{plotmath}} for the use of \code{sqrt} in plot annotation.
2 r 44
}
24300 ripley 45
\references{
88581 hornik 46
  \bibshow{R:Becker+Chambers+Wilks:1988}
24300 ripley 47
}
2 r 48
\examples{
27712 ripley 49
require(stats) # for spline
41508 ripley 50
require(graphics)
2 r 51
xx <- -9:9
52
plot(xx, sqrt(abs(xx)),  col = "red")
27712 ripley 53
lines(spline(xx, sqrt(abs(xx)), n=101), col = "pink")
2 r 54
}
286 maechler 55
\keyword{math}