Trig
Trigonometric Functions

### Description

Returns the cosine, sine, or tangent transformation of a numeric or complex valued object.

### Usage

    cos(x)
    sin(x)
    tan(x)
    cospi(x)
    sinpi(x)
    tanpi(x)

### Arguments

x | a numeric or, for cos, sin, or tan, a complex object. The units are radians for cos, sin, and tan and radians/pi for cospi, sinpi, and tanpi. Missing values (NAs) are allowed.

### Details

Missing values in the input create missing values in the output.
cos, sin, tan, cospi, sinpi, and tanpi are members of the Math group of generic functions.
See section 5.1.5 of Becker, Chambers and Wilks (1988) for details on domains and branch cuts in the case of complex arguments.
For information about inverse trigonometric functions, see acos. For information about hyperbolic functions, see cosh.
Value

cos(x), sin(x), and tan(x) | return x with each element transformed by the specified trigonometric function, with attributes preserved.
cospi(x), sinpi(x), and tanpi(x) | return the results of multiplying x by pi, and then applying the trigonometic function. The returned value should be more accurate than the results of doing this in the naive way, especially when x is close to multiples of pi/2.

Classes
These functions are used as the default methods 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.
References
Becker, R. A., Chambers, J. M., and Wilks, A. R. 1988. The New S Language. Pacific Grove, CA: Wadsworth & Brooks/Cole Advanced Books and Software.
See Also
acos, cosh, acosh.
Examples

    my.matrix <- matrix(seq(1, 2*pi, len=12), nrow=4)
    cos(my.matrix) # produces a matrix of the same dimensions
    1/sin(my.matrix) # cosecant of my.matrix
    1/tan(my.matrix) # cotangent of my.matrix
    sin(pi/2)
    # [1] 1
    sin(100*pi) # a number close to zero
    sinpi(100)  # zero

Package base version 6.1.5-18
Package Index