1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<h1 id="firstHeading" class="firstHeading">cexpf, cexp, cexpl</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><complex.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float complex cexpf( float complex z );</pre>
</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double complex cexp( double complex z );</pre>
</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double complex cexpl( long double complex z );</pre>
</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code><tgmath.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define exp( z )</pre>
</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <div class="t-li1">
<span class="t-li">1-3)</span> Computes the complex base-<i>e</i> exponential of <code>z</code>.</div> <div class="t-li1">
<span class="t-li">4)</span> Type-generic macro: If <code>z</code> has type <code><span class="kw4">long</span> <span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code>cexpl</code> is called. if <code>z</code> has type <code><span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code>cexp</code> is called, if <code>z</code> has type <code><span class="kw4">float</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code>cexpf</code> is called. If <code>z</code> is real or integer, then the macro invokes the corresponding real function (<code>expf</code>, <code><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code>, <code>expl</code>). If <code>z</code> is imaginary, the corresponding complex argument version is called.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> z </td> <td> - </td> <td> complex argument </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, <i>e</i> raised to the power of <code>z</code>, \(\small e^z\)e<sup class="t-su">z</sup> is returned.</p>
<h3 id="Error_handling_and_special_values"> Error handling and special values</h3> <p>Errors are reported consistent with <a href="../math/math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p>
<p>If the implementation supports IEEE floating-point arithmetic,</p>
<ul>
<li> <code>cexp<span class="br0">(</span><a href="http://en.cppreference.com/w/c/numeric/complex/conj"><span class="kw760">conj</span></a><span class="br0">(</span>z<span class="br0">)</span><span class="br0">)</span> <span class="sy1">==</span> <a href="http://en.cppreference.com/w/c/numeric/complex/conj"><span class="kw760">conj</span></a><span class="br0">(</span>cexp<span class="br0">(</span>z<span class="br0">)</span><span class="br0">)</span></code> </li>
<li> If <code>z</code> is <code>±0+0i</code>, the result is <code>1+0i</code> </li>
<li> If <code>z</code> is <code>x+∞i</code> (for any finite x), the result is <code>NaN+NaNi</code> and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> is raised. </li>
<li> If <code>z</code> is <code>x+NaNi</code> (for any finite x), the result is <code>NaN+NaNi</code> and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> may be raised. </li>
<li> If <code>z</code> is <code>+∞+0i</code>, the result is <code>+∞+0i</code> </li>
<li> If <code>z</code> is <code>-∞+yi</code> (for any finite y), the result is <code>+0cis(y)</code> </li>
<li> If <code>z</code> is <code>+∞+yi</code> (for any finite nonzero y), the result is <code>+∞cis(y)</code> </li>
<li> If <code>z</code> is <code>-∞+∞i</code>, the result is <code>±0±0i</code> (signs are unspecified) </li>
<li> If <code>z</code> is <code>+∞+∞i</code>, the result is <code>±∞+NaNi</code> and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> is raised (the sign of the real part is unspecified) </li>
<li> If <code>z</code> is <code>-∞+NaNi</code>, the result is <code>±0±0i</code> (signs are unspecified) </li>
<li> If <code>z</code> is <code>+∞+NaNi</code>, the result is <code>±∞+NaNi</code> (the sign of the real part is unspecified) </li>
<li> If <code>z</code> is <code>NaN+0i</code>, the result is <code>NaN+0i</code> </li>
<li> If <code>z</code> is <code>NaN+yi</code> (for any nonzero y), the result is <code>NaN+NaNi</code> and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> may be raised </li>
<li> If <code>z</code> is <code>NaN+NaNi</code>, the result is <code>NaN+NaNi</code> </li>
</ul> <p>where \(\small{\rm cis}(y)\)cis(y) is \(\small \cos(y)+{\rm i}\sin(y)\)cos(y) + i sin(y)</p>
<h3 id="Notes"> Notes</h3> <p>The complex exponential function \(\small e^z\)e<sup class="t-su">z</sup> for \(\small z = x + {\rm i}y\)z = x+iy equals \(\small e^x {\rm cis}(y)\)e<sup class="t-su">x</sup> cis(y), or, \(\small e^x (\cos(y)+{\rm i}\sin(y))\)e<sup class="t-su">x</sup> (cos(y) + i sin(y))</p>
<p>The exponential function is an <i>entire function</i> in the complex plane and has no branch cuts.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
double PI = acos(-1);
double complex z = cexp(I * PI); // Euler's formula
printf("exp(i*pi) = %.1f%+.1fi\n", creal(z), cimag(z));
}</pre></div> <p>Output:</p>
<div class="text source-text"><pre data-language="c">exp(i*pi) = -1.0+0.0i</pre></div> </div> <h3 id="References"> References</h3> <ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.3.7.1 The cexp functions (p: 194) </li>
<li> 7.25 Type-generic math <tgmath.h> (p: 373-375) </li>
<li> G.6.3.1 The cexp functions (p: 543) </li>
<li> G.7 Type-generic math <tgmath.h> (p: 545) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.3.7.1 The cexp functions (p: 176) </li>
<li> 7.22 Type-generic math <tgmath.h> (p: 335-337) </li>
<li> G.6.3.1 The cexp functions (p: 478) </li>
<li> G.7 Type-generic math <tgmath.h> (p: 480) </li>
</ul>
</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="clog" title="c/numeric/complex/clog"> <span class="t-lines"><span>clog</span><span>clogf</span><span>clogl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes the complex natural logarithm <br> <span class="t-mark">(function)</span> </td>
</tr> <tr class="t-dsc"> <td> <div><a href="../math/exp" title="c/numeric/math/exp"> <span class="t-lines"><span>exp</span><span>expf</span><span>expl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes <i>e</i> raised to the given power (\({\small e^x}\)e<sup>x</sup>) <br> <span class="t-mark">(function)</span> </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/complex/exp" title="cpp/numeric/complex/exp">C++ documentation</a></span> for <code>exp</code> </td>
</tr> </table> <div class="_attribution">
<p class="_attribution-p">
© cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
<a href="https://en.cppreference.com/w/c/numeric/complex/cexp" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/cexp</a>
</p>
</div>
|