Name
cexp
Synopsis
Calculates the natural exponential of a complex number
#include <complex.h> double complexcexp
( double complexz
); float complexcexpf
( float complexz
); long double complexcexpl
( long double complexz
);
The return value of the cexp()
function is e raised to the power of the function’s
argument, or ez, where
e is Euler’s number,
2.718281.... Furthermore, in complex mathematics, ezi =
cos(z
) +
sin(z
) × i for any complex number
z
.
Tip
The natural exponential function cexp()
is the inverse of the natural
logarithm, clog()
.
Example
// Demonstrate Euler's theorem in the form
// e^(I*z) = cos(z) + I * sin(z)
double complex z = 2.2 + 3.3 * I;
double complex c, d;
c =cexp
( z * I );
d = ccos( z ) + csin( z ) * I ;
printf( "cexp( z*I ) yields %.2f %+.2f \xD7 I.\n",
creal(c), cimag(c) );
printf( "ccos( z ) + csin( z ) * I yields %.2f %+.2f \xD7 I.\n",
creal(d), cimag(d) );
This code produces the following output:
cexp( z*I ) yields -0.02 +0.03 × I. ccos( z ) + csin( z ) * I yields -0.02 +0.03 × 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.