Go to the first, previous, next, last section, table of contents.


Trigonometric Functions

These are the familiar sin, cos, and tan functions. The arguments to all of these functions are in units of radians; recall that pi radians equals 180 degrees.

The math library doesn't define a symbolic constant for pi, but you can define your own if you need one:

#define PI 3.14159265358979323846264338327

You can also compute the value of pi with the expression acos (-1.0).

Function: double sin (double x)
This function returns the sine of x, where x is given in radians. The return value is in the range -1 to 1.

Function: double cos (double x)
This function returns the cosine of x, where x is given in radians. The return value is in the range -1 to 1.

Function: double tan (double x)
This function returns the tangent of x, where x is given in radians.

The following errno error conditions are defined for this function:

ERANGE
Mathematically, the tangent function has singularities at odd multiples of pi/2. If the argument x is too close to one of these singularities, tan sets errno to ERANGE and returns either positive or negative HUGE_VAL.


Go to the first, previous, next, last section, table of contents.