TRIG(3M) TRIG(3M)
sin, cos, tan, asin, acos, atan, atan2, fsin, sinf, fcos, cosf, ftan,
tanf, fasin, asinf, facos, acosf, fatan, atanf, fatan2, atan2f, sinl,
cosl, tanl, asinl, acosl, atanl, atan2l - trigonometric functions and
their inverses
#include <math.h>
double sin(double x);
float fsin(float x);
float sinf(float x);
long double sinl(long double x);
double cos(double x);
float fcos(float x);
float cosf(float x);
long double cosl(long double x);
double tan(double x);
float ftan(float x);
float tanf(float x);
long double tanl(long double x);
double asin(double x);
float fasin(float x);
float asinf(float x);
long double asinl(long double x);
double acos(double x);
float facos(float x);
float acosf(float x);
long double acosl(long double x);
double atan(double x);
float fatan(float x);
float atanf(float x);
long double atanl(long double x);
double atan2(double y, double x);
float fatan2(float y, float x);
float atan2f(float y, float x);
long double atan2l(long double y, \
long double x);
The single-precision and long double-precision routines listed above are
only available in the standard math library, -lm, and in -lmx.
sin, cos and tan return trigonometric functions of radian arguments x for
double data types. fsin, fcos and ftan, and their ANSI-named
counterparts sinf, cosf and tanf return trigonometric functions of radian
Page 1
TRIG(3M) TRIG(3M)
arguments x for float data types. sinl, cosl and tanl do the same for
long double data types.
The asin routines return the arc sine in the range -pi/2 to pi/2. The
type of both the return value and the single argument are double for
asin, float for fasin and its ANSI-named counterpart asinf, and long
double for asinl.
The acos routines return the arc cosine in the range 0 to pi. The type
of both the return value and the single argument are double for acos,
float for facos and its ANSI-named counterpart acosf, and long double for
acosl.
The atan routines return the arc tangent in the range -pi/2 to pi/2. The
type of both the return value and the single argument are double for
atan, float for fatan and its ANSI-named counterpart atanf, and long
double for atanl.
The atan2 routines return the arctangent of y/x in the range -pi to pi
using the signs of both arguments to determine the quadrant of the return
value. Both the return value and the argument types are double for
atan2, float for fatan2 and its ANSI-named counterpart atan2f, and long
double for atan2l.
In the diagnostics below, functions in the standard math library libm.a,
are referred to as -lm versions, and those in the the BSD math library
libm43.a, are referred to as -lm43 versions. The -lm versions always
return the default Quiet NaN and set errno to EDOM when a NaN is used as
an argument. A NaN argument usually causes the -lm43 versions to return
the same argument. The -lm43 versions never set errno.
If |x| > 1 the -lm versions of the asin and acos functions set errno to
EDOM and return NaN. When the argument is greater than one, the return
value of the -lm43 versions is indeterminate.
The atan2 functions will return zero if both arguments are zero. The -lm
versions also set errno to EDOM. (Exception: the -lm43 versions return
the following results:
atan2(0.0, 0.0) = 0.0
atan2(-0.0, 0.0) = -0.0
atan2(0.0, -0.0) = pi
atan2(-0.0, -0.0) = -pi )
See matherr(3M) for a description of error handling for -lmx functions.
Single precision routines fsin, fcos, and ftan are accurate to within 1
ulp for arguments in the range -2**22 to 2**22. Double precision
routines sin, cos, and tan are accurate to within 2 ulps for arguments in
the range -2**28 to 2**28. Arguments larger than this lose precision
rapidly, but retain more than 20 bits precision out to +/-2**50 for the
Page 2
TRIG(3M) TRIG(3M)
double routines.
Long double operations on this system are only supported in round to
nearest rounding mode (the default). The system must be in round to
nearest rounding mode when calling any of the long double functions, or
incorrect answers will result.
Users concerned with portability to other computer systems should note
that the long double and float versions of these functions are optional
according to the ANSI C Programming Language Specification ISO/IEC 9899 :
1990 (E).
Long double functions have been renamed to be compliant with the ANSI-C
standard, however to be backward compatible, they may still be called
with the double precision function name prefixed with a q.
The reasons for assigning a value to atan2(0,0) are these:
(1) 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.
(2) atan2 is used mostly to convert from rectangular (x,y) to polar
(r,theta) coordinates that must satisfy x = r*cos theta and y = r*sin
theta. These equations are satisfied when (x=0,y=0) is mapped to
(r=0,theta=0) In general, conversions to polar coordinates should be
computed thus:
r:= hypot(x,y); ... := sqrt(x*x+y*y)
theta:= atan2(y,x).
(3) The foregoing formulas need not be altered to cope in a reasonable
way with signed zeros and infinities on machines, such as SGI 4D
machines, that conform 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:
r := sqrt(x*x+y*y); if r = 0 then x := copysign(1,x);
if x > 0 then theta := 2*atan(y/(r+x))
else theta := 2*atan((r-x)/y);
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.
math(3M), hypot(3M), sqrt(3M), matherr(3M)
Robert P. Corbett, W. Kahan, Stuart I. McDonald, Peter Tang and, for the
codes for IEEE 754, Dr. Kwok-Choi Ng.
Page 3
SIN(3F) SIN(3F)
sin, dsin, qsin, csin, zsin, cqsin, sind, dsind, qsind - FORTRAN sine
intrinsic function
real r1, r2
double precision dp1, dp2
real*16 qp1, qp2
complex cx1, cx2
complex*16 cd1, cd2
complex*32 cq1, cq2
real*4 r3, r4
real*8 dp3, dp4
real*16 qp3, qp4
r2 = sin(r1)
dp2 = dsin(dp1)
dp2 = sin(dp1)
qp2 = qsin(qp1)
qp2 = sin(qp1)
cx2 = csin(cx1)
cx2 = sin(cx1)
cd2 = zsin(cd1)
cd2 = sin(cd1)
cq2 = cqsin(cq1)
cq2 = sin(cq1)
r4 = sind(r3)
dp4 = dsind(dp3)
dp4 = sind(dp3)
qp4 = qsind(qp3)
qp4 = sind(qp3)
sin returns the real sine of its real argument. dsin returns the
double-precision sine of its double-precision argument. qsin returns the
real*16 sine of its real*16 argument. csin returns the complex sine of
its complex argument. zsin returns the complex*16 sine of its complex*16
argument. cqsin returns the complex*32 sine of its complex*32 argument.
The argument for these functions must be in radians and is treated modulo
2*Pi.
The generic sin function becomes dsin, qsin, csin, zsin, or cqsin as
required by argument type.
Page 1
SIN(3F) SIN(3F)
sind returns the real*4 sine of its real*4 argument. dsind returns the
real*8 sine of its real*8 argument, and qsind returns the real*16 sine of
its real*16 argument. The argument for sind, dsind, and qsind must be in
degrees and is treated as modulo 360.
The generic sind function becomes dsind or qsind as required by argument
type.
trig(3M).
Page 2
SIN(3M) Last changed: 2-12-98
SIN, DSIN, CSIN, CDSIN - Computes the sine
UNICOS and UNICOS/mk systems:
SIN ([X=]x)
DSIN ([X=]x)
CSIN ([X=]x)
UNICOS and IRIX systems:
CDSIN ([X=]x)
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
CDSIN is a compiler extension to Fortran 90.
CDSIN is the generic function name. These functions are CF90
elemental functions.
A vector version of this intrinsic exists on UNICOS and UNICOS/mk
systems. On UNICOS/mk systems, the vector version of this intrinsic
is used when -h vector3 (C compiler) or -O vector3 or -O3 (Fortran
compiler) has been specified on the compiler command line.
The entry point CDSIN is provided for support in other languages. It
is not recognized as an intrinsic function; therefore, you must use
the CDIR$ VFUNCTION directive to allow vectorization.
These functions evaluate y = sin(x).
CF90 [Toc] [Back]
CDSIN is called implicitly by the Fortran 90 compiler as a result of a
generic SIN call with a complex double-precision argument.
CAL Register Usage (Cray Research Systems Only)
Scalar SIN: SIN% (call-by-register)
on entry (S1) = argument
on exit (S1) = result
Vector SIN: %SIN% (call-by-register)
on entry (V1) = argument vector
on exit (V1) = result vector
Scalar DSIN: DSIN% (call-by-register)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector DSIN: %DSIN% (call-by-register)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CSIN: CSIN% (call-by-register)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector CSIN: %CSIN% (call-by-register)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CDSIN: CSDIN% (call-by-register)
on entry (S1), (S2), (S3), and (S4) = argument
on exit (S1), (S2), (S3), and (S4) = result
Vector CDSIN: %CSDIN% (call-by-register)
on entry (V1), (V2), (V3), and (V4) = argument vecto
on exit (V1), (V2), (V3), and (V4) = result vector
Argument Range [Toc] [Back]
SIN:
25
|x| < 2
DSIN:
45
|x| < 2
25
On UNICOS/mk systems, |x| < 2
CSIN:
25 13
|x | < 2 , |x | < 2 * ln2
r i 25
On UNICOS/mk systems, |x|< 2 , |x | < 710.47586
i
CDSIN:
45 13
|x | < 2 , |x | < 2 * ln2
r i CDSIN is an outmoded routine for the CF90 compiler. Refer to the
Fortran Language Reference Manual, Volume 3, publication SR-3905, for
information about outmoded features and their preferred standard
alternatives.
The name of the SIN, DSIN, and CSIN intrinsic can be passed as an
argument. The name of the CDSIN intrinsic cannot be passed as an
argument.
SIN returns the real sine of its real argument.
DSIN returns the double-precision sine of its double-precision
argument.
CSIN returns the complex sine of its complex argument.
CDSIN returns the complex double-precision sine of its complex
double-precision argument.
On CRAY T90 systems that support IEEE arithmetic, the following return
values occur:
25
SIN(x) = NaN if |x| > 2
SIN(NaN) = NaN
Additional entry points are available on IRIX systems. See the IRIX
man pages for details.
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.
SIN(3M) Last changed: 2-12-98
SIN, DSIN, CSIN, CDSIN - Computes the sine
UNICOS and UNICOS/mk systems:
SIN ([X=]x)
DSIN ([X=]x)
CSIN ([X=]x)
UNICOS and IRIX systems:
CDSIN ([X=]x)
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
CDSIN is a compiler extension to Fortran 90.
CDSIN is the generic function name. These functions are CF90
elemental functions.
A vector version of this intrinsic exists on UNICOS and UNICOS/mk
systems. On UNICOS/mk systems, the vector version of this intrinsic
is used when -h vector3 (C compiler) or -O vector3 or -O3 (Fortran
compiler) has been specified on the compiler command line.
The entry point CDSIN is provided for support in other languages. It
is not recognized as an intrinsic function; therefore, you must use
the CDIR$ VFUNCTION directive to allow vectorization.
These functions evaluate y = sin(x).
CF90 [Toc] [Back]
CDSIN is called implicitly by the Fortran 90 compiler as a result of a
generic SIN call with a complex double-precision argument.
CAL Register Usage (Cray Research Systems Only)
Scalar SIN: SIN% (call-by-register)
on entry (S1) = argument
on exit (S1) = result
Vector SIN: %SIN% (call-by-register)
on entry (V1) = argument vector
on exit (V1) = result vector
Scalar DSIN: DSIN% (call-by-register)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector DSIN: %DSIN% (call-by-register)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CSIN: CSIN% (call-by-register)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector CSIN: %CSIN% (call-by-register)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CDSIN: CSDIN% (call-by-register)
on entry (S1), (S2), (S3), and (S4) = argument
on exit (S1), (S2), (S3), and (S4) = result
Vector CDSIN: %CSDIN% (call-by-register)
on entry (V1), (V2), (V3), and (V4) = argument vecto
on exit (V1), (V2), (V3), and (V4) = result vector
Argument Range [Toc] [Back]
SIN:
25
|x| < 2
DSIN:
45
|x| < 2
25
On UNICOS/mk systems, |x| < 2
CSIN:
25 13
|x | < 2 , |x | < 2 * ln2
r i 25
On UNICOS/mk systems, |x|< 2 , |x | < 710.47586
i
CDSIN:
45 13
|x | < 2 , |x | < 2 * ln2
r i CDSIN is an outmoded routine for the CF90 compiler. Refer to the
Fortran Language Reference Manual, Volume 3, publication SR-3905, for
information about outmoded features and their preferred standard
alternatives.
The name of the SIN, DSIN, and CSIN intrinsic can be passed as an
argument. The name of the CDSIN intrinsic cannot be passed as an
argument.
SIN returns the real sine of its real argument.
DSIN returns the double-precision sine of its double-precision
argument.
CSIN returns the complex sine of its complex argument.
CDSIN returns the complex double-precision sine of its complex
double-precision argument.
On CRAY T90 systems that support IEEE arithmetic, the following return
values occur:
25
SIN(x) = NaN if |x| > 2
SIN(NaN) = NaN
Additional entry points are available on IRIX systems. See the IRIX
man pages for details.
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.
[ Back ]
|