complex - STL C++

cosh()

Declaration

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

Description

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

cosh(z) = (e^(z) + e^(-z))/2.

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

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

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

Output

cosh() Output
 

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