Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::exp(std::complex)

      From cppreference.com
      <cpp‎ |numeric‎ |complex
       
       
       
       
      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

      [edit]Parameters

      z - complex value

      [edit]Return value

      If no errors occur,e raised to the power ofz,\(\small e^z\)ez
      , is returned.

      [edit]Error handling and special values

      Errors are reported consistent withmath_errhandling.

      If the implementation supports IEEE floating-point arithmetic,

      • std::exp(std::conj(z))==std::conj(std::exp(z))
      • Ifz is(±0,+0), the result is(1,+0)
      • Ifz is(x,+∞) (for any finite x), the result is(NaN,NaN) andFE_INVALID is raised.
      • Ifz is(x,NaN) (for any finite x), the result is(NaN,NaN) andFE_INVALID may be raised.
      • Ifz is(+∞,+0), the result is(+∞,+0)
      • Ifz is(-∞,y) (for any finite y), the result is+0cis(y)
      • Ifz is(+∞,y) (for any finite nonzero y), the result is+∞cis(y)
      • Ifz is(-∞,+∞), the result is(±0,±0) (signs are unspecified)
      • Ifz is(+∞,+∞), the result is(±∞,NaN) andFE_INVALID is raised (the sign of the real part is unspecified)
      • Ifz is(-∞,NaN), the result is(±0,±0) (signs are unspecified)
      • Ifz is(+∞,NaN), the result is(±∞,NaN) (the sign of the real part is unspecified)
      • Ifz is(NaN,+0), the result is(NaN,+0)
      • Ifz is(NaN,y) (for any nonzero y), the result is(NaN,NaN) andFE_INVALID may be raised
      • Ifz is(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).

      [edit]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 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.

      [edit]Example

      Run this code
      #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)

      [edit]See also

      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]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/complex/exp&oldid=150848"

      [8]ページ先頭

      ©2009-2025 Movatter.jp