Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ acosf(3M) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

trigd(3M)

isinf(3M)

isnan(3M)

matherr(3M)

trig(3M)

NAME

sin(), cos(), tan(), asin(), acos(), atan(), atan2(), sinf(), cosf(), tanf(), asinf(), acosf(), atanf(), atan2f() − trigonometric functions

SYNOPSIS

#include <math.h>

double sin(double x);

double cos(double x);

double tan(double x);

double asin(double x);

double acos(double x);

double atan(double x);

double atan2(double y, double x);

float sinf(float x);

float cosf(float x);

float tanf(float x);

float asinf(float x);

float acosf(float x);

float atanf(float x);

float atan2f(float y, float x);

DESCRIPTION

The following trigonometric functions return the values indicated:

sin(x) sine of x (x specified in radians)

cos(x) cosine of x (x specified in radians)

tan(x) tangent of x (x specified in radians)

asin(x) arcsine of x in the range −π/2 to π/2. 

acos(x) arccosine of x in the range 0 to π. 

atan(x) arctangent of x in the range −π/2 to π/2.  If x is ±INFINITY , atan() returns ±π/2 respectively. 

atan2(y,x) arctangent of y/x, in the range −π to π, using the signs of both arguments to determine the quadrant of the return value.

Other atan2() returns:

• π/4 when y and x are +INFINITY. 

• 3∗π/4 when y is +INFINITY and x is −INFINITY. 

• −π/4 when y is −INFINITY and x is +INFINITY. 

• −3∗π/4 when y and x are −INFINITY. 

• 0.0 when y is 0.0 and x is a positive number. 

• π when y is 0.0 and x is a negative number, or −π when y is -0.0 and x is a negative number. 

• π/2 when y is a positive number and x is 0.0, or −π/2 when y is a negative number and x is 0.0. 

• ±π/2 if y/x would overflow.  The result will be π/2 if y is a positive number and −π/2 if y is a negative number. 

• ±π or 0.0 if y/x would underflow.  The result is 0.0 if x is a positive number, π if x is a negative number and y is a positive number, and −π if x and y are both negative numbers. 

sinf(), cosf(), tanf(), asinf(), acosf(), atanf(), and atan2f() are float versions of these functions; they take float arguments and return float results.  Their performance is significantly faster than that of the double versions of the functions.  Programs must be  compiled in ANSI mode (use the -Aa option) in order to use these functions; otherwise, the compiler promotes the float arguments to double, and the functions return incorrect results. 

DEPENDENCIES

Series 300/400

sinf(), cosf(), tanf(), asinf(), acosf(), atanf(), and atan2f() are not supported on Series 300/400 systems. 

Series 700/800

sinf(), cosf(), tanf(), asinf(), acosf(), atanf(), and atan2f() are not specified by any standard (they are, however, named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard).  These functions are provided in the PA1.1 versions of the math library only.  The +DA1.1 option (the default on Series 700 systems) links in a PA1.1 version automatically.  A PA1.1 library can be linked in explicitly.  For more information, see the HP-UX Floating-Point Guide.

ERRORS

/lib/libm.a

sin(), cos(), and tan() lose accuracy when their argument is far from zero.  For arguments sufficiently large, these functions return 0.0 when there would otherwise be a complete loss of significance.  In this case a message indicating TLOSS error is printed on the standard error output.  For less extreme arguments causing partial loss of significance, a PLOSS error is generated but no message is printed.  In both cases, errno is set to ERANGE. 

If the magnitude of the argument of asin() or acos() is greater than one, or if both arguments of atan2() are 0.0, 0.0 is returned and errno is set to EDOM.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

sin(), cos(), tan(), acos(), and asin() return NaN and set errno to EDOM when x is NaN or ±INFINITY.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

atan() returns NaN and sets errno to EDOM when x is NaN.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

atan2() returns NaN and sets errno to EDOM when x or y is NaN.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

These error-handling procedures can be changed with the matherr() function (see matherr(3M)).

/lib/libM.a

No error messages are printed on the standard error output. 

sin(), cos(), and tan() lose accuracy when their argument is far from zero.  For arguments sufficiently large, these functions return 0.0 when there would otherwise be a complete loss of significance.  For less extreme arguments causing partial loss of significance, a PLOSS error is generated.  In both cases, errno is set to ERANGE. 

If the magnitude of the argument of asin() or acos() is greater than one, NaN is returned and errno is set to EDOM. 

If both arguments of atan2() are 0.0, 0.0 is returned and errno is set to EDOM. 

sin(), cos(), tan(), acos(), and asin() return NaN and set errno to EDOM when x is NaN or ±INFINITY. 

atan() returns NaN and sets errno to EDOM when x is NaN. 

atan2() returns NaN and sets errno to EDOM when x or y is NaN. 

These error-handling procedures can be changed with the function _matherr() (see matherr(3M)). Note that _matherr() is provided in order to assist in migrating programs from libm.a to libM.a and is not a part of XPG3, ANSI C, or POSIX. 

SEE ALSO

trigd(3M), isinf(3M), isnan(3M), matherr(3M). 

STANDARDS CONFORMANCE

acos() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
acos() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

asin() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
asin() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

atan() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
atan() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

atan2() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
atan2() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

cos() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
cos() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

sin() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
sin() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

tan() in libm.a: AES, SVID2, XPG2, XPG3, FIPS 151-2, POSIX.1
tan() in libM.a: AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Hewlett-Packard Company  —  HP-UX Release 9.10: April 1995

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