Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
Defined in header <complex> | ||
template<class T> std::complex<T> exp(conststd::complex<T>& z); | ||
Compute base-e exponential ofz, that ise (Euler's number,2.7182818
) raised to thez power.
Contents |
z | - | complex value |
If no errors occur,e raised to the power ofz,\(\small e^z\)ez
, is returned.
Errors are reported consistent withmath_errhandling.
If the implementation supports IEEE floating-point arithmetic,
(±0,+0)
, the result is(1,+0)
(x,+∞)
(for any finite x), the result is(NaN,NaN)
andFE_INVALID is raised.(x,NaN)
(for any finite x), the result is(NaN,NaN)
andFE_INVALID may be raised.(+∞,+0)
, the result is(+∞,+0)
(-∞,y)
(for any finite y), the result is+0cis(y)
(+∞,y)
(for any finite nonzero y), the result is+∞cis(y)
(-∞,+∞)
, the result is(±0,±0)
(signs are unspecified)(+∞,+∞)
, the result is(±∞,NaN)
andFE_INVALID is raised (the sign of the real part is unspecified)(-∞,NaN)
, the result is(±0,±0)
(signs are unspecified)(+∞,NaN)
, the result is(±∞,NaN)
(the sign of the real part is unspecified)(NaN,+0)
, the result is(NaN,+0)
(NaN,y)
(for any nonzero y), the result is(NaN,NaN)
andFE_INVALID may be raised(NaN,NaN)
, the result is(NaN,NaN)
where\(\small{\rm cis}(y)\)cis(y) is\(\small \cos(y)+{\rm i}\sin(y)\)cos(y) + i sin(y).
The complex exponential function\(\small e^z\)ez
for\(\small z = x + {\rm i}y\)z = x+iy equals\(\small e^x {\rm cis}(y)\)ex
cis(y), or,\(\small e^x (\cos(y)+{\rm i}\sin(y))\)ex
(cos(y) + i sin(y)).
The exponential function is anentire function in the complex plane and has no branch cuts.
The following have equivalent results when the real part is 0:
In this caseexp
can be about 4.5x slower. One of the other forms should be used instead of callingexp
with an argument whose real part is literal 0. There is no benefit in trying to avoidexp
with a runtime check ofz.real()==0 though.
#include <cmath>#include <complex>#include <iostream> int main(){constdouble pi=std::acos(-1.0);conststd::complex<double> i(0.0,1.0); std::cout<<std::fixed<<" exp(i * pi) = "<<std::exp(i* pi)<<'\n';}
Output:
exp(i * pi) = (-1.000000,0.000000)
complex natural logarithm with the branch cuts along the negative real axis (function template)[edit] | |
(C++11)(C++11) | returnse raised to the given power (\({\small e^x}\)ex) (function)[edit] |
applies the functionstd::exp to each element of valarray (function template)[edit] | |
constructs a complex number from magnitude and phase angle (function template)[edit] | |
C documentation forcexp |