
- 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
tanh( ) function for complex Number in C++
In this article we will be discussing the working, syntax and examples of tanh() function for a complex number in C++ STL.
tanh() for complex number is a function which comes under <complex> header file. This function is used to find the hyperbolic tangent of a complex number. This is the complex version of the tanh() which is under the <cmath> header file.
What is tanh?
Tanh is the hyperbolic tangent function. To easily define the function, we can say that the tanh is equal to hyperbolic sine divided by hyperbolic cosine.
Syntax
complex<T> tanh(complex& num);
Parameters
The function accepts only one parameter which is num, of complex type.
Return value
It returns hyperbolic of tangent num.
Example
Input: complex <double> num(0.0, 1.0); tanh(num); Output: (0, 1.55741) Input: complex <double> num(1.0, 0.0); tanh(num); Output: (0.761594, 0)
Approach can be followed −
- In main function, we define the complex number.
- Then we print the complex.
- At last we print the hyperbolic tangent of complex Number.
By this approach we can find out the hyperbolic tangent of complex Number.
Example
C++ code to demonstrate the working of tanh( ) function
#include<iostream.h> #include<complex.h> #include<cmath.h> using namespace std; int main( ) { / / defining complex number Complex<double> x(1,0); Cout<< “ tanh “<<x<<” =” << tanh(x)<<endl; return 0; }
Output
If we run the above code it will generate the following output −
tanh(1.000000,0.000000) = (0.761594, 0.000000) tanh(0.000000,1.000000) = (0.000000, 1.557408)
- 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++?
- log() function for complex number in C++
- log10() function for complex number in C++
- tan() 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++
