Trig                  package:base                  R Documentation

_T_r_i_g_o_n_o_m_e_t_r_i_c _F_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     These functions give the obvious trigonometric functions.  They
     respectively compute the cosine, sine, tangent, arc-cosine,
     arc-sine, arc-tangent, and the two-argument arc-tangent.

_U_s_a_g_e:

     cos(x)
     sin(x)
     tan(x)
     acos(x)
     asin(x)
     atan(x)
     atan2(y, x)

_A_r_g_u_m_e_n_t_s:

    x, y: numeric vector

_D_e_t_a_i_l_s:

     The arc-tangent of two arguments `atan2(y,x)' returns the angle
     between the x-axis and the vector from the origin to (x,y), i.e.,
     for positive arguments `atan2(y,x) == atan(y/x)'.

     Angles are in radians, not degrees (i.e. a right angle is pi/2).

_E_x_a_m_p_l_e_s:

     cos(0) == 1
     sin(3*pi/2) == cos(pi)
     x <- rnorm(99)
     all.equal( sin(-x), - sin(x))
     all.equal( cos(-x), cos(x))
     x <- abs(x); y <- abs(rnorm(x))
     all(abs(atan2(y, x) - atan(y/x)) <= .Machine$double.eps)# TRUE
     table(abs(atan2(y, x) - atan(y/x)) / .Machine$double.eps) # depends!

     x <- 1:99/100
     all(Mod(1 - (cos(x) + 1i*sin(x)) / exp(1i*x)) < 1.1 * .Machine$double.eps)
      2* abs(1 - x / acos(cos(x))) / .Machine$double.eps #-- depends ?
     all(abs(1 - x / asin(sin(x))) <= .Machine$double.eps) # TRUE
     all(abs(1 - x / atan(tan(x))) <= .Machine$double.eps) # TRUE

