C++ Standard Library C++ STL Library

C++ <complex> - exp() Function



The C++ <complex> exp() function returns base-e exponential of a complex number z, that is e (Euler's number, 2.7182818) raised to the power of z, ez. It is a function on complex plane, and has no branch cuts.

Mathematically, it can be expressed as:

complex exp

where, z = x+iy

Syntax

template<class T> 
  complex<T> exp (const complex<T>& z);

Parameters

z Specify the complex number.

Return Value

Returns e raised to the power of z.

Example:

The example below shows the usage of exp() function.

#include <iostream>
#include <complex>
using namespace std;
 
int main (){
  complex<double> z1 (2, 2);
  complex<double> z2 (2, 0);
  complex<double> z3 (0, 2);

  //calculate the exponential of given value
  cout<<"exp(z1): "<<exp(z1)<<"\n";
  cout<<"exp(z2): "<<exp(z2)<<"\n";
  cout<<"exp(z3): "<<exp(z3)<<"\n";

  return 0;
}

The output of the above code will be:

exp(z1): (-3.07493,6.71885)
exp(z2): (7.38906,0)
exp(z3): (-0.416147,0.909297)

❮ C++ <complex> Library

5