| Types and the imaginary constant | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Manipulation | |||||||||||||||||||||||||||||||
| Power and exponential functions | |||||||||||||||||||||||||||||||
| Trigonometric functions | |||||||||||||||||||||||||||||||
| Hyperbolic functions | |||||||||||||||||||||||||||||||
Defined in header <complex.h> | ||
| (1) | (since C99) | |
| (2) | (since C99) | |
| (3) | (since C99) | |
Defined in header <tgmath.h> | ||
#define cos( z ) | (4) | (since C99) |
z.z has typelongdoublecomplex,ccosl is called. ifz has typedoublecomplex,ccos is called, ifz has typefloatcomplex,ccosf is called. Ifz is real or integer, then the macro invokes the corresponding real function (cosf,cos,cosl). Ifz is imaginary, then the macro invokes the corresponding real version of the functioncosh, implementing the formulacos(iy) = cosh(y), and the return type is real.Contents |
| z | - | complex argument |
If no errors occur, the complex cosine ofz is returned.
Errors and special cases are handled as if the operation is implemented byccosh(I*z).
The cosine is an entire function on the complex plane, and has no branch cuts.
Mathematical definition of the cosine iscos z =| eiz +e-iz |
| 2 |
#include <stdio.h>#include <math.h>#include <complex.h> int main(void){doublecomplex z= ccos(1);// behaves like real cosine along the real lineprintf("cos(1+0i) = %f%+fi ( cos(1)=%f)\n",creal(z),cimag(z),cos(1)); doublecomplex z2= ccos(I);// behaves like real cosh along the imaginary lineprintf("cos(0+1i) = %f%+fi (cosh(1)=%f)\n",creal(z2),cimag(z2),cosh(1));}
Output:
cos(1+0i) = 0.540302-0.000000i ( cos(1)=0.540302)cos(0+1i) = 1.543081-0.000000i (cosh(1)=1.543081)
(C99)(C99)(C99) | computes the complex sine (function)[edit] |
(C99)(C99)(C99) | computes the complex tangent (function)[edit] |
(C99)(C99)(C99) | computes the complex arc cosine (function)[edit] |
(C99)(C99) | computes cosine (\({\small\cos{x} }\)cos(x)) (function)[edit] |
C++ documentation forcos | |