Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
exp() function for complex number in C++
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.
Example
Input
exp(complex<double> complexnumber(-1.0, 0.0));
Output
The result is : (-1, 0) is (0.367879, 0)
Example
#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
#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)
Advertisements