exp
Exponential and related Functions

### Description

Returns the exponential, logarithm, or square root of the input.

### Usage

    exp(x)
    log(x, base = exp(1))
    logb(x, base = exp(1))
    log10(x)
    log2(x)
    sqrt(x)
    log1p(x)
    expm1(x)

### Arguments

x | a numeric or a complex. Missing values (NAs) are allowed. log1p and expm1 do not accept complex inputs.
base | a (positive) numeric or complex base for logarithms.

### Details

Missing input means missing output. Numeric arguments must be non-negative for log, logb, log10, log2, and sqrt, arguments must be bigger than -1 for log1p; otherwise, NaN is returned. Coerce the numbers to complex to avoid this.
The functions exp, log, expm1, and log1p are members of the Math group of generic functions. Because members of this group have only one argument, the logb function replaces the log function when you need to specify a base for the logarithm, when missing base, logb is same as log. log10 and log2 call logb with base equal to 10 and 2, respectively.
Value
returns data transformed by the specified function, with attributes preserved (for example, a matrix remains a matrix).

log | computes natural logs.
logb, log10, log2 | computes logarithms for particular base.
log1p(x) | computes log(1+x) but avoids the loss of precision in computing 1+x when x is close to 0.
expm1(x) | computes exp(x)-1 but avoids the loss of precision when exp(x) is close to 1.
sqrt | returns square root of x.

Classes
This function is used as the default method for classes that do not inherit a specific method for the function or for the Math group of functions. The result retains the class and the attributes. If this behavior is not appropriate, the designer of the class should provide a method for the function or for the Math group.
See Also
Complex, Arithmetic (for exponentiation).
Examples

    log2(64)  # base 2 logarithms
    logb(100, 10) == log10(100)  # log10 computes the common logarithm
    log(-3)  # returns NaN
    log(as.complex(-3))  # equals log(3) plus pi times i
    arc <- seq(0, pi/2, len=13)
    exp((1i) * arc)	 # part of the unit circle in the complex plane
    exp(3)
    expm1(3)
    sqrt(2)
    sqrt(-2+0i)
    log1p(3)
    log1p(1e-10)  # slightly less than 1e-10
    log1p(1e-20)  # c. 1e-20, not the 0 that log(1+1e-20) gives
    expm1(1e-20)  # c. 1e-20, not the 0 that exp(1e-20)-1 gives

Package base version 6.1.5-18
Package Index