exp() function for complex number in C++

C++Server Side ProgrammingProgramming

In this article we will be discussing the working, syntax and examples of std::exp() function for complex numbers in C++ STL.

What is std::exp()?

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.

Syntax

exp(complex <T> num);

Parameters

The function accepts the following parameter(s) −

• num − It is a complex number whose exponential we are wishing to find.

Return value

This function returns the exponential value of num.

Input

exp(complex<double> complexnumber(-1.0, 0.0));

Output

The result is : (-1, 0) is (0.367879, 0)

Example

Live Demo

#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;
}

Output

The result is : (-1, 0) is (0.367879, 0)

Example

Live Demo

#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;
}

Output

The result is : (0, 1) is (0.540302,0.841471)