BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libm / common_source / sin.3
index 50d7035..f88816b 100644 (file)
-.\" Copyright (c) 1985 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1991 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)sin.3       6.6 (Berkeley) %G%
+.\"    @(#)sin.3       6.7 (Berkeley) 4/19/91
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
 .\"
 .\"
-.TH SIN 3M  ""
-.UC 4
-.de Pi         \" PI stuff sign
-.if n \\
-\\$2pi\\$1
-.if t \\
-\\$2\\(*p\\$1
-..
-.ds up \fIulp\fR
-.SH NAME
-sin, cos, tan, asin, acos, atan, atan2 \- trigonometric functions
-and their inverses
-.SH SYNOPSIS
-.nf
-.B #include <math.h>
-.PP
-.B double sin(x)
-.B double x;
-.PP
-.B double cos(x)
-.B double x;
-.PP
-.B double tan(x)
-.B double x;
-.PP
-.B double asin(x)
-.B double x;
-.PP
-.B double acos(x)
-.B double x;
-.PP
-.B double atan(x)
-.B double x;
-.PP
-.B double atan2(y,x)
-.B double y,x;
-.fi
-.SH DESCRIPTION
-Sin, cos and tan
-return trigonometric functions of radian arguments x.
-.PP
-Asin returns the arc sine in the range 
-.Pi /2 \-
-to
-.Pi /2.
-.PP
-Acos returns the arc cosine in the range 0 to
-.Pi.
-.PP
-Atan returns the arc tangent in the range
-.Pi /2 \-
-to
-.Pi /2.
-.PP
-On a VAX,
-.nf
-.if n \{\
-.ta \w'atan2(y,x) := 'u+2n +\w'sign(y)\(**(pi \- atan(|y/x|))'u+2n
-atan2(y,x) :=  atan(y/x)       if x > 0,
-       sign(y)\(**(pi \- atan(|y/x|))  if x < 0,
-       0       if x = y = 0, or
-       sign(y)\(**pi/2 if x = 0 != y.  \}
-.if t \{\
-.ta \w'atan2(y,x) := 'u+2n +\w'sign(y)\(**(\(*p \- atan(|y/x|))'u+2n
-atan2(y,x) :=  atan(y/x)       if x > 0,
-       sign(y)\(**(\(*p \- atan(|y/x|))        if x < 0,
-       0       if x = y = 0, or
-       sign(y)\(**\(*p/2       if x = 0 \(!= y.  \}
-.ta
-.fi
-.SH DIAGNOSTICS
-On a VAX, if |x| > 1 then asin(x) and acos(x)
-will return reserved operands and \fIerrno\fR will be set to EDOM.
-.SH NOTES
-Atan2 defines atan2(0,0) = 0 on a VAX despite that previously
-atan2(0,0) may have generated an error message.
-The reasons for assigning a value to atan2(0,0) are these:
-.IP (1) \w'\0\0\0\0'u
-Programs that test arguments to avoid computing
-atan2(0,0) must be indifferent to its value.
-Programs that require it to be invalid are vulnerable
-to diverse reactions to that invalidity on diverse computer systems. 
-.IP (2) \w'\0\0\0\0'u
-Atan2 is used mostly to convert from rectangular (x,y)
-to polar
-.if n\
-(r,theta)
-.if t\
-(r,\(*h)
-coordinates that must satisfy x =
-.if n\
-r\(**cos theta
-.if t\
-r\(**cos\(*h
-and y =
-.if n\
-r\(**sin theta.
-.if t\
-r\(**sin\(*h.
-These equations are satisfied when (x=0,y=0)
-is mapped to 
-.if n \
-(r=0,theta=0)
-.if t \
-(r=0,\(*h=0)
-on a VAX.  In general, conversions to polar coordinates
-should be computed thus:
-.nf
-.ta 1iR +1n +\w' := hypot(x,y);'u+0.5i
-.if n \{\
-       r       := hypot(x,y);  ... := sqrt(x\(**x+y\(**y)
-       theta   := atan2(y,x).
-.ta \}
-.if t \{\
-       r       := hypot(x,y);  ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
-       \(*h    := atan2(y,x).
-.ta \}
-.fi
-.IP (3) \w'\0\0\0\0'u
-The foregoing formulas need not be altered to cope in a
-reasonable way with signed zeros and infinities
-on a machine that conforms to IEEE 754;
-the versions of hypot and atan2 provided for
-such a machine are designed to handle all cases.
-That is why atan2(\(+-0,\-0) =
-.Pi , \(+-
-for instance.
-In general the formulas above are equivalent to these:
-.RS
-.nf
-.if n \
-r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x);
-.if t \
-r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);
-.br
-.if n \
-.ta 1i
-.if t \
-.ta \w'if x > 0'u+2n +\w'then'u+2n
-.if n \
-if x > 0       then theta := 2\(**atan(y/(r+x))
-.if t \
-if x > 0       then    \(*h := 2\(**atan(y/(r+x))
-.if n \
-       else theta := 2\(**atan((r\-x)/y);
-.if t \
-       else    \(*h := 2\(**atan((r\-x)/y);
-.fi
-.RE
-except if r is infinite then atan2 will yield an
-appropriate multiple of
-.Pi /4
-that would otherwise have to be obtained by taking limits.
-.SH ERROR (due to Roundoff etc.)
-Let P stand for the number stored in the computer in place of
-.Pi " = 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
-.Pi /P), trig(x\(**
-and "atrig(x)" approximates
-.Pi )\(**atrig(x). (P/
-The approximations are close,  within 0.9 \*(ups for sin,
-cos and atan, within 2.2 \*(ups for tan, asin,
-acos and atan2 on a VAX.  Moreover,
-.Pi \& "P = "
-in the codes that run on a VAX.
-
-In the codes that run on other machines, P differs from
-.Pi
-by a fraction of an \*(up; 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
-.Pi
-explicitly is satisfied equally well regardless of whether
-.Pi . "P = "
-For instance,
-.if n \
-sin(x)**2+cos(x)**2\0=\01
-.if t \
-sin\u\s62\s10\d(x)+cos\u\s62\s10\d(x)\0=\01
-and sin(2x)\0=\02\|sin(x)cos(x) to within a few \*(ups no matter how big
-x may be.  Therefore the difference between P and
-.Pi
-is most unlikely to affect scientific and engineering computations.
-.SH SEE ALSO
-math(3M), hypot(3M), sqrt(3M), infnan(3M)
-.SH AUTHOR
-Robert P. Corbett, W. Kahan, Stuart\0I.\0McDonald, Peter\0Tang and,
-for the codes for IEEE 754, Dr. Kwok\-Choi\0Ng.
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)sin.3      6.7 (Berkeley) 4/19/91
+.\"
+.Dd April 19, 1991
+.Dt SIN 3
+.Os
+.Sh NAME
+.Nm sin
+.Nd sine function
+.Sh SYNOPSIS
+.Fd #include <math.h>
+.Ft double
+.Fn sin "double x"
+.Sh DESCRIPTION
+The
+.Fn sin
+function computes the sine of
+.Fa x
+(measured in radians).
+A large magnitude argument may yield a result with little
+or no significance.
+.Sh RETURN VALUES
+The
+.Fn sin
+function returns the sine value.
+.Sh SEE ALSO
+.Xr acos 3 ,
+.Xr asin 3 ,
+.Xr atan 3 ,
+.Xr atan2 3 ,
+.Xr cos 3 ,
+.Xr cosh 3 ,
+.Xr sinh 3 ,
+.Xr tan 3 ,
+.Xr tanh 3 ,
+.Xr math 3 ,
+.Sh STANDARDS
+The
+.Fn sin
+function conforms to
+.St -ansiC .