log                   package:base                   R Documentation

_L_o_g_a_r_i_t_h_m_s _a_n_d _E_x_p_o_n_e_n_t_i_a_l_s

_D_e_s_c_r_i_p_t_i_o_n:

     'log' computes logarithms, by default natural logarithms,  'log10'
     computes common (i.e., base 10) logarithms, and 'log2' computes
     binary (i.e., base 2) logarithms. The general form 'log(x, base)'
     computes logarithms with base 'base'.

     'log1p(x)' computes log(1+x) accurately also for |x| << 1 (and
     less accurately when x is approximately -1).

     'exp' computes the exponential function.

     'expm1(x)' computes exp(x) - 1 accurately also for |x| << 1.

_U_s_a_g_e:

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

     log1p(x)

     exp(x)
     expm1(x)

_A_r_g_u_m_e_n_t_s:

       x: a numeric or complex vector.

    base: a positive or complex number: the base with respect to which
          logarithms are computed.  Defaults to e='exp(1)'.

_D_e_t_a_i_l_s:

     All except 'logb' are generic functions: methods can be defined
     for them individually or via the 'Math' group generic.

     'log10' and '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 'logb' itself.

_V_a_l_u_e:

     A vector of the same length as 'x' containing the transformed
     values.  'log(0)' gives '-Inf', and negative values give 'NaN'.

_S_4 _m_e_t_h_o_d_s:

     'exp', 'expm1', 'log', 'log10', 'log2' and 'log1p' are S4 generic
     and are members of the 'Math' group generic.

     Note that this means that the S4 generic for 'log' has a signature
     with only one argument, 'x', but that 'base' can be passed to
     methods (but will not be used for method selection).  On the other
     hand, if you only set a method for the 'Math' group generic then
     'base' argument of 'log' will be ignored for your class.

_N_o_t_e:

     'log' and 'logb' are the same thing in R, but 'logb' is preferred
     if 'base' is specified, for S-PLUS compatibility.

_S_o_u_r_c_e:

     'log1p' and 'expm1' may be taken from the operating system, but if
     not available there are based on the Fortran subroutine 'dlnrel'
     by W. Fullerton of Los Alamos Scientific Laboratory (see <URL:
     http://www.netlib.org/slatec/fnlib/dlnrel.f> and (for small x) a
     single Newton step for the solution of 'log1p(y) = x'
     respectively.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole. (for 'log', 'log10' and
     'exp'.)

     Chambers, J. M. (1998) _Programming with Data. A Guide to the S
     Language_. Springer. (for 'logb'.)

_S_e_e _A_l_s_o:

     'Trig', 'sqrt', 'Arithmetic'.

_E_x_a_m_p_l_e_s:

     log(exp(3))
     log10(1e7)# = 7

     x <- 10^-(1+2*1:9)
     cbind(x, log(1+x), log1p(x), exp(x)-1, expm1(x))

