trig(3M)


trig -- trigonometric functions

Synopsis

   cc [flag ...] file ...  -lm [library ...] 
   

#include <math.h>

double sin(double x);

float sinf(float x);

double cos(double x);

float cosf(float x);

double tan(double x);

float tanf(float x);

double asin(double x);

float asinf(float x);

double acos(double x);

float acosf(float x);

double atan(double x);

float atanf(float x);

double atan2(double y, double x);

float atan2f(float y, float x);

Description

sin, cos, and tan and the single-precision versions sinf, cosf, and tanf return, respectively, the sine, cosine, and tangent of their argument, x, measured in radians.

asin and asinf return the arcsine of x, in the range [-GREEK SMALL LETTER PI/2,+GREEK SMALL LETTER PI/2].

acos and acosf return the arccosine of x, in the range [0,+GREEK SMALL LETTER PI].

atan and atanf return the arctangent of x, in the range (-GREEK SMALL LETTER PI/2,+GREEK SMALL LETTER PI/2).

atan2 and atan2f return the arctangent of y/ in the range (-GREEK SMALL LETTER PI,+GREEK SMALL LETTER PI], using the signs of both arguments to determine the quadrant of the return value.

Errors

If the magnitude of the argument to asin, asinf, acos, or acosf is greater than 1, they return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return zero. In either case, errno is set to EDOM.

On systems that support signed zeroes, if the second argument to atan2 and atan2f is +0 and the first argument is ±0, these functions return ±0, depending on the sign of the first argument. When the second argument to atan2 or atan2f is -0 and the first argument is ±0, these functions return ±GREEK SMALL LETTER PI, depending on the sign of the first argument. On systems that do not support signed zeroes, if both arguments to atan2 and atan2f are zero, the return value is zero. In each of these cases, errno is set to EDOM.

On systems that support IEEE infinity, if the argument to sin, sinf, cos, cosf, tan or tanf is ±INFINITY, they return IEEE NaN, raise the invalid operation exception and set errno to EDOM.

On systems that support IEEE NaN, if any of the arguments to any of these functions is a quiet NaN, that value is returned. If any of the arguments is a signaling NaN, a quiet NaN is returned and the invalid operation exception is raised. In either case, errno is set to EDOM.

If the program was compiled with the -Xt compilation mode, if the magnitude of the argument to asin, asinf, acos, or acosf is greater than 1 or when both arguments to atan2 or atan2f are zero, they return zero and set errno to EDOM. In addition, a message indicating DOMAIN error is printed on the standard error output. These error handling procedures may be changed with the function matherr.

References

cc(1), matherr(3M)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.