Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

hypot(3M)

math(3M)

sqrt(3M)

SIN(3M)  —  

NAME

sin, cos, tan, asin, acos, atan, atan2 − trigonometric functions and their inverses

SYNOPSIS

#include <math.h>

double sin(x)
double x;

double cos(x)
double x;

double tan(x)
double x;

double asin(x)
double x;

double acos(x)
double x;

double atan(x)
double x;

double atan2(y, x)
double y, x;

DESCRIPTION

Sin, cos and tan return trigonometric functions of radian arguments. 

Asin returns the arc sin in the range −π/2 to π/2. 

Acos returns the arc cosine in the range 0 to π. 

Atan returns the arc tangent of x in the range −π/2 to π/2. 

Atan2 returns
atan(y/x)   if x > 0,
sign(y)∗(π − atan(|y/x|))     if x < 0,
x   if x = 0 and y = +0,
sign(y)∗π   if x = 0 and y = -0, and
sign(y)∗π/2 if x = 0 but y not equal to 0. 

DIAGNOSTICS

Arguments of magnitude greater than 1 cause asin and acos to return a NaN; errno is set to EDOM. 

ERRORS (due to roundoff etc.)

Let P stand for the number stored in the computer in place of π = 3.14159 26535 89793 23846 26433 ... .  Let “trig” stand for one of “sin”, “cos” or “tan”.  Then the expression “trig(x)” in a program actually produces an approximation to trig(x∗π/P), and “atrig(x)” approximates (P/π)∗atrig(x). 

P differs from π by a fraction of an ulp; the difference matters only if the argument x is huge, and even then the difference is likely to be swamped by the uncertainty in x.  Besides, every trigonometric identity that does not involve π explicitly is satisfied equally well regardless of whether P = π.  For instance, sin(x)+cos(x)=1 and sin(2x)=2sin(x)cos(x) to within a few ulps no matter how big x may be.  Therefore the difference between P and π is most unlikely to affect scientific and engineering computations. 

NOTES

The three trig functions: sin, cos, and tan call static routines cos__C() and sin__S().  When profiling programs calling the trig functions, use the -a flag for prof(1) or compile with -pg and use gprof(1).  This will give you statistics for the static routines. 

SEE ALSO

hypot(3M), math(3M), sqrt(3M)
 

PRPQs 5799-WZQ/5799-PFF: IBM/4.3  —  July 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026