In this article we will be discussing the working, syntax and examples of std::exp() function for complex numbers in C++ STL.
std::exp() function for complex numbers is an inbuilt function in C++ STL, which is defined in a <complex> header file. exp() function for complex numbers is the same like the normal exp() which is also an inbuilt function, defined in <cmath> header file, used to find the exponential value of the input.This function is exponential of the complex number and returns the exponential of the complex number.
exp(complex <T> num);
The function accepts the following parameter(s) −
This function returns the exponential value of num.
exp(complex<double> complexnumber(-1.0, 0.0));
The result is : (-1, 0) is (0.367879, 0)
#include <bits/stdc++.h> using namespace std; int main(){ complex<double> complexnumber(-1.0, 0.0); cout<<"The result is : " << complexnumber<< " is "<< exp(complexnumber)<< endl; return 0; }
The result is : (-1, 0) is (0.367879, 0)
#include <bits/stdc++.h> using namespace std; int main(){ complex<double> complexnumber(0.0, 1.0); cout<<"The result is : " << complexnumber<< " is "<< exp(complexnumber)<< endl; return 0; }
The result is : (0, 1) is (0.540302,0.841471)