logcomputes logarithms, by default natural logarithms,
log10computes common (i.e., base 10) logarithms, and
log2computes binary (i.e., base 2) logarithms. The general form
log(x, base)computes logarithms with base
log1p(x) computes $log(1+x)$ accurately also for
$|x| << 1$.
exp computes the exponential function.
expm1(x) computes $exp(x) - 1$ accurately also for
$|x| << 1$.
log(x, base = exp(1)) logb(x, base = exp(1)) log10(x) log2(x)log1p(x)exp(x) expm1(x)
xcontaining the transformed values.
log(x)for negative values of
0.For complex inputs to the log functions, the value is a complex number with imaginary part in the range $[-pi, pi]$: which end of the range is used might be platform-specific.
log1pare S4 generic and are members of the
Mathgroup generic. Note that this means that the S4 generic for
loghas a signature with only one argument,
x, but that
basecan be passed to methods (but will not be used for method selection). On the other hand, if you only set a method for the
Mathgroup generic then
logwill be ignored for your class.
expm1may be taken from the operating system, but if not available there then they are based on the Fortran subroutine
dlnrelby W. Fullerton of Los Alamos Scientific Laboratory (see http://www.netlib.org/slatec/fnlib/dlnrel.f and (for small x) a single Newton step for the solution of
log1p(y) = xrespectively.
logbare generic functions: methods can be defined for them individually or via the
log2 are only convenience wrappers, but logs
to bases 10 and 2 (whether computed via
log or the wrappers)
will be computed more efficiently and accurately where supported by the OS.
Methods can be set for them individually (and otherwise methods for
log will be used).
logb is a wrapper for
log for compatibility with S. If
(S3 or S4) methods are set for
log they will be dispatched.
Do not set S4 methods on
log are primitive functions.
Chambers, J. M. (1998)
Programming with Data. A Guide to the S Language.
log(exp(3)) log10(1e7) # = 7 x <- 10^-(1+2*1:9) cbind(x, log(1+x), log1p(x), exp(x)-1, expm1(x))