complex - STL C++

tanh()

Declaration

complex<X> tanh(const complex<X>& kqrZ);

Description

This is the friend function tanh() for complex numbers. It returns the hyperbolic tangent of the complex number kqrZ, which is equal to (exp(kqrZ) - exp(-kqrZ))/(exp(kqrZ) + exp(-kqrZ)). The formula for the hyperbolic tangent of a complex number z is

tanh(z) = (e^(z) - e^(-z))/(e^(z) + e^(-z)).

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create a complex number and calculate its hyperbolic tangent
	complex<double> qZ(2.0, 4.0);
	cout << "Complex Number : "<< qZ << endl;
	cout << "The hyperbolic tangent is "<< tanh(qZ) << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

tanh() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.