EVOLUTION-MANAGER
Edit File: Trig.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Trigonometric Functions</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Trig {base}"><tr><td>Trig {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Trigonometric Functions</h2> <h3>Description</h3> <p>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. </p> <p><code>cospi(x)</code>, <code>sinpi(x)</code>, and <code>tanpi(x)</code>, compute <code>cos(pi*x)</code>, <code>sin(pi*x)</code>, and <code>tan(pi*x)</code>. </p> <h3>Usage</h3> <pre> cos(x) sin(x) tan(x) acos(x) asin(x) atan(x) atan2(y, x) cospi(x) sinpi(x) tanpi(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>numeric or complex vectors.</p> </td></tr> </table> <h3>Details</h3> <p>The arc-tangent of two arguments <code>atan2(y, x)</code> returns the angle between the x-axis and the vector from the origin to <i>(x, y)</i>, i.e., for positive arguments <code>atan2(y, x) == atan(y/x)</code>. </p> <p>Angles are in radians, not degrees, for the standard versions (i.e., a right angle is <i>π/2</i>), and in ‘half-rotations’ for <code>cospi</code> etc. </p> <p><code>cospi(x)</code>, <code>sinpi(x)</code>, and <code>tanpi(x)</code> are accurate for <code>x</code> values which are multiples of a half. </p> <p>All except <code>atan2</code> are <a href="InternalMethods.html">internal generic</a> <a href="Primitive.html">primitive</a> functions: methods can be defined for them individually or via the <code><a href="groupGeneric.html">Math</a></code> group generic. </p> <p>These are all wrappers to system calls of the same name (with prefix <code>c</code> for complex arguments) where available. (<code>cospi</code>, <code>sinpi</code>, and <code>tanpi</code> are part of a C11 extension and provided by e.g. macOS and Solaris: where not yet available call to <code>cos</code> <em>etc</em> are used, with special cases for multiples of a half.) </p> <h3>Value</h3> <p><code>tanpi(0.5)</code> is <code><a href="is.finite.html">NaN</a></code>. Similarly for other inputs with fractional part <code>0.5</code>. </p> <h3>Complex values</h3> <p>For the inverse trigonometric functions, branch cuts are defined as in Abramowitz and Stegun, figure 4.4, page 79. </p> <p>For <code>asin</code> and <code>acos</code>, there are two cuts, both along the real axis: <i>(-Inf, -1]</i> and <i>[1, Inf)</i>. </p> <p>For <code>atan</code> there are two cuts, both along the pure imaginary axis: <i>(-1i*Inf, -1i]</i> and <i>[1i, 1i*Inf)</i>. </p> <p>The behaviour actually on the cuts follows the C99 standard which requires continuity coming round the endpoint in a counter-clockwise direction. </p> <p>Complex arguments for <code>cospi</code>, <code>sinpi</code>, and <code>tanpi</code> are not yet implemented, and they are a ‘future direction’ of ISO/IEC TS 18661-4. </p> <h3>S4 methods</h3> <p>All except <code>atan2</code> are S4 generic functions: methods can be defined for them individually or via the <code><a href="../../methods/html/S4groupGeneric.html">Math</a></code> group generic. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Abramowitz, M. and Stegun, I. A. (1972). <em>Handbook of Mathematical Functions</em>. New York: Dover.<br /> Chapter 4. Elementary Transcendental Functions: Logarithmic, Exponential, Circular and Hyperbolic Functions </p> <p>For <code>cospi</code>, <code>sinpi</code>, and <code>tanpi</code> the C11 extension ISO/IEC TS 18661-4:2015 (draft at <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1950.pdf">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1950.pdf</a>). </p> <h3>Examples</h3> <pre> 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) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>