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 normally defines M_PI to a double
approximation of pi. If strict ISO and/or POSIX compliance
are requested this constant is not defined, but you can easily define it
yourself:
#define M_PI 3.14159265358979323846264338327
You can also compute the value of pi with the expression acos
(-1.0).
double sin (double x) ¶float sinf (float x) ¶long double sinl (long double x) ¶_FloatN sinfN (_FloatN x) ¶_FloatNx sinfNx (_FloatNx x) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the sine of x, where x is given in
radians. The return value is in the range -1 to 1.
double cos (double x) ¶float cosf (float x) ¶long double cosl (long double x) ¶_FloatN cosfN (_FloatN x) ¶_FloatNx cosfNx (_FloatNx x) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the cosine of x, where x is given in
radians. The return value is in the range -1 to 1.
double tan (double x) ¶float tanf (float x) ¶long double tanl (long double x) ¶_FloatN tanfN (_FloatN x) ¶_FloatNx tanfNx (_FloatNx x) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the tangent of x, where x is given in radians.
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 will signal overflow.
In many applications where sin and cos are used, the sine
and cosine of the same angle are needed at the same time. It is more
efficient to compute them simultaneously, so the library provides a
function to do that.
void sincos (double x, double *sinx, double *cosx) ¶void sincosf (float x, float *sinx, float *cosx) ¶void sincosl (long double x, long double *sinx, long double *cosx) ¶_FloatN sincosfN (_FloatN x, _FloatN *sinx, _FloatN *cosx) ¶_FloatNx sincosfNx (_FloatNx x, _FloatNx *sinx, _FloatNx *cosx) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the sine of x in *sinx and the
cosine of x in *cosx, where x is given in
radians. Both values, *sinx and *cosx, are in
the range of -1 to 1.
All these functions, including the _FloatN and
_FloatNx variants, are GNU extensions. Portable programs
should be prepared to cope with their absence.
ISO C99 defines variants of the trig functions which work on complex numbers. The GNU C Library provides these functions, but they are only useful if your compiler supports the new complex types defined by the standard. (As of this writing GCC supports complex numbers, but there are bugs in the implementation.)
complex double csin (complex double z) ¶complex float csinf (complex float z) ¶complex long double csinl (complex long double z) ¶complex _FloatN csinfN (complex _FloatN z) ¶complex _FloatNx csinfNx (complex _FloatNx z) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the complex sine of z. The mathematical definition of the complex sine is
sin (z) = 1/(2*i) * (exp (z*i) - exp (-z*i)).
complex double ccos (complex double z) ¶complex float ccosf (complex float z) ¶complex long double ccosl (complex long double z) ¶complex _FloatN ccosfN (complex _FloatN z) ¶complex _FloatNx ccosfNx (complex _FloatNx z) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the complex cosine of z. The mathematical definition of the complex cosine is
cos (z) = 1/2 * (exp (z*i) + exp (-z*i))
complex double ctan (complex double z) ¶complex float ctanf (complex float z) ¶complex long double ctanl (complex long double z) ¶complex _FloatN ctanfN (complex _FloatN z) ¶complex _FloatNx ctanfNx (complex _FloatNx z) ¶Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the complex tangent of z. The mathematical definition of the complex tangent is
tan (z) = -i * (exp (z*i) - exp (-z*i)) / (exp (z*i) + exp (-z*i))
The complex tangent has poles at pi/2 + 2n, where n is an
integer. ctan may signal overflow if z is too close to a
pole.