December 2005
Beginner to intermediate
618 pages
20h 19m
English
ccos
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.
/* 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.
Read now
Unlock full access