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 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' (`log10' and `log2' are only special cases).

     `log1p(x)' computes log(1+x) accurately also for |x| << 1 (and
     less accurately when x ~= -1).

     `exp' computes the exponential function.

_U_s_a_g_e:

     log(x)
     log(x, base)
     log10(x)
     log2(x)
     exp(x)
     log1p(x)

_A_r_g_u_m_e_n_t_s:

       x: a numeric or complex vector.

    base: positive number. The base with respect to which logarithms
          are computed.  Defaults to e=`exp(1)'.

_V_a_l_u_e:

     A vector of the same length as `x' containing the transformed
     values.  `log(0)' gives `-Inf' (when available).

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     log(exp(3))
     all.equal(log(1:10), log(1:10, exp(1)))
     log10(30) == log(30, 10)
     log10(1e7)# = 7
     log2(2^pi) == 2^log2(pi)
     Mod(pi - log(exp(pi*1i)) / 1i) < .Machine$double.eps
     Mod(1+exp(pi*1i)) < .Machine$double.eps

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

