Open In App

tan() function for complex number in C++

Improve
Improve
Like Article
Like
Save
Share
Report

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




// C++ program to demonstrate
// example of tan() function.
#include <iostream>
#include <complex>
using namespace std;
  
 
int main ()
{
  complex<double> complexnumber (0.0, 1.0);
  
  
  // use of tan() function for complex number
  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




// C++ program to demonstrate
// example of tan() function.
#include <iostream>
#include <complex>
using namespace std;
 
int main ()
{
  complex<double> complexnumber (1.0, 0.0);
  
  
  // use of tan() function for complex number
  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)



Last Updated : 17 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads