Learn R Programming

rkeops (version 2.2.2)

default.trigo.fun: Trigonometric Functions

Description

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.

cospi(x), sinpi(x), and tanpi(x), compute cos(pi*x), sin(pi*x), and tan(pi*x).

Usage

# S3 method for default
cos(x)

# S3 method for default sin(x)

# S3 method for default acos(x)

# S3 method for default asin(x)

# S3 method for default atan(x)

# S3 method for default atan2(x, y)

Value

tanpi(0.5) is NaN. Similarly for other inputs with fractional part 0.5.

Arguments

x, y

numeric or complex vectors.

Author

R core team and contributors

Details

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, for the standard versions (i.e., a right angle is \(\pi/2\)), and in ‘half-rotations’ for cospi etc.

cospi(x), sinpi(x), and tanpi(x) are accurate for x values which are multiples of a half.

All except atan2 are internal generic primitive functions: methods can be defined for them individually or via the Math group generic.

These are all wrappers to system calls of the same name (with prefix c for complex arguments) where available. (cospi, sinpi, and tanpi are part of a C11 extension and provided by e.g. macOS and Solaris: where not yet available call to cos etc are used, with special cases for multiples of a half.)

See Also

Examples

Run this code
x <- seq(-3, 7, by = 1/8)
tx <- cbind(x, cos(pi*x), cospi(x), sin(pi*x), sinpi(x),
               tan(pi*x), tanpi(x), deparse.level=2)
op <- options(digits = 4, width = 90) # for nice formatting
head(tx)
tx[ (x %% 1) %in% c(0, 0.5) ,]
options(op)

Run the code above in your browser using DataLab