tan() function for complex number in C++
Last Updated :
17 Aug, 2022
The tan() function for complex numbers is defined in the complex header file. This function is the complex version of the tan() function. This function is used to calculate the complex tan of the complex number z. This function returns the tan of complex number z.
Syntax:
tan(z);
Parameter:
- z: This method takes a mandatory parameter z which represents the complex number.
Return value: This function returns the tan() of complex number z.
Below programs illustrate the tan() function in C++:
Program 1:
CPP
#include <iostream>
#include <complex>
using namespace std;
int main ()
{
complex< double > complexnumber (0.0, 1.0);
cout << "The tan of " << complexnumber << " is "
<< tan (complexnumber) <<endl;
return 0;
}
|
Output:
The tan of (0,1) is (0,0.761594)
Time Complexity: O(1)
Auxiliary Space: O(1)
PROGRAM 2:-
CPP
#include <iostream>
#include <complex>
using namespace std;
int main ()
{
complex< double > complexnumber (1.0, 0.0);
cout << "The tan of " << complexnumber << " is "
<< tan (complexnumber) << endl;
return 0;
}
|
Output:
The tan of (1,0) is (1.55741,0)
Time Complexity: O(1)
Auxiliary Space: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...