
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
tan() function for complex number in C++
In this article we will be discussing the working, syntax and examples of tan() function for complex numbers in C++ STL.
tan() for complex numbers is a function which comes under the <complex> header file. This function is used to find the tangent of the complex number associated with it. This function is the complex version of simple tan() which comes under <cmath> header file.
What are complex numbers?
Complex numbers are the numbers which are the combination of real number and imaginary number.
They are written as: a+bi
Where a and b are the real numbers and i is an imaginary number.
Syntax
template<class T> complex<T> tan (const complex<T>& num);
Parameters
The function accepts only one parameter which is num, which is an complex value.
Return value
It returns the tangent value of num.
Example
Input: complex <double> num(0.0, 1.0); tan(num); Output: (0, 1.55741)
Example
#include <iostream> #include <complex> using namespace std; int main () { complex<double> tan_num(9.1, 2.6); cout<<"tan of "<<tan_num<<" is "<<tan(tan_num); return 0; }
Output
If we run the above code it will generate the following output −
tan of (9.1, 2.6) is (-0.00661488, 0.99123)
Example
#include <iostream> #include <complex> using namespace std; int main () { complex<double> tan_num(1.0, 0.0); cout<<"tan of "<<tan_num<<" is "<<tan(tan_num); return 0; }
Output
If we run the above code it will generate the following output −
tan of (1, 0) is (1.55741, 0)
- Related Articles
- arg() function for Complex Number in C++
- abs() function for complex number in c++ ?
- acosh() function for complex number in C++
- acos() function for complex number in C++?
- asin() function for complex number in C++?
- atan() function for complex number in C++?
- tanh( ) function for complex Number in C++
- log() function for complex number in C++
- log10() function for complex number in C++
- Cos() function for complex number in C++
- pow() function for complex number in C++
- polar() function for complex number in C++
- exp() function for complex number in C++
- sqrt ( ) function for complex number in C++
- Sinh( ) function for complex number in C++
