Name
ccos
Synopsis
Calculates the cosine of a complex number
#include <complex.h> double complexccos
( double complexz
); float complexccosf
( float complexz
); long double complexccosl
( long double complexz
);
The ccos()
function returns
the cosine of its complex number argument
z
, which is equal to
(eiz +
e−iz)/2.
Example
/* Demonstrate the exponential definition
* of the complex cosine function.
*/
double complex z = 2.2 + 3.3 * I;
double complex c, d;
c =ccos
( z );
d = 0.5 * ( cexp( z * I ) + cexp( − z * I ));
printf( "The ccos() function returns %.2f %+.2f \xD7 I.\n",
creal(c), cimag(c) );
printf( "Using the cexp() function, the result is %.2f %+.2f \xD7 I.\n",
creal(d), cimag(d) );
This code produces the following output:
The ccos() function returns -7.99 -10.95 × I. Using the cexp() function, the result is -7.99 -10.95 × I.
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.