std::exp(std::complex)(3)
πΈ NAME πΈ
std::exp(std::complex) β and the name is literally std::exp(std::complex) again, because the page says std::exp(std::complex) - std::exp(std::complex). Keeping it consistent, bestie π
.
β¨ Synopsis β¨
Defined in header <complex>:
template< class T >
std::complex<T> exp( const std::complex<T>& z );
Compute base-e exponential of z, that is e (Euler's number, 2.7182818) raised to the z power.
π Parameters π
zβ complex value.
π Return value π
If no errors occur, e raised to the power of z, (\small e^z)ez, is returned.
π«Ά Error handling and special values π«Ά
Errors are reported consistent with math_errhandling.
If the implementation supports IEEE floating-point arithmetic, then:
std::exp(std::conj(z)) == std::conj(std::exp(z))- If
zis(Β±0,+0), the result is(1,+0) - If
zis(x,+β)(for any finitex), the result is(NaN,NaN)andFE_INVALIDis raised. - If
zis(x,NaN)(for any finitex), the result is(NaN,NaN)andFE_INVALIDmay be raised. - If
zis(+β,+0), the result is(+β,+0) - If
zis(-β,y)(for any finitey), the result is+0cis(y) - If
zis(+β,y)(for any finite nonzeroy), the result is+βcis(y) - If
zis(-β,+β), the result is(Β±0,Β±0)(signs are unspecified) - If
zis(+β,+β), the result is(Β±β,NaN)andFE_INVALIDis raised (the sign of the real part is unspecified) - If
zis(-β,NaN), the result is(Β±0,Β±0)(signs are unspecified) - If
zis(+β,NaN), the result is(Β±β,NaN)(the sign of the real part is unspecified) - If
zis(NaN,+0), the result is(NaN,+0) - If
zis(NaN,y)(for any nonzeroy), the result is(NaN,NaN)andFE_INVALIDmay be raised - If
zis(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).
π¦ Notes π¦
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 an entire function in the complex plane and has no branch cuts.
The following have equivalent results when the real part is 0:
std::exp(std::complex<float>(0, theta))std::complex<float>(cosf(theta), sinf(theta))std::polar(1.f, theta)
In this case exp can be about 4.5x slower. One of the other forms should be used instead of calling exp with an argument whose real part is literal 0. There is no benefit in trying to avoid exp with a runtime check of z.real() == 0 though.
π Example π
// Run this code
#include <cmath>
#include <complex>
#include <iostream>
int main()
{
const double pi = std::acos(-1.0);
const std::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)
π See also π
log(std::complex)β complex natural logarithm with the branch cuts along the negative real axis (function template).exp,expf,explβ returnseraised to the given power ((\small e^x)e^x) (function). The(C++11)(C++11)markers are there forexpfandexpl, so don't lose them.exp(std::valarray)β applies the functionstd::expto each element ofvalarray(function template).polarβ constructs a complex number from magnitude and phase angle (function template).- C documentation for
cexpβ the C-side docs, bestie.
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::exp(std::complex)(3) β mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms