Skip to content
Related Articles

Related Articles

Improve Article

cosh() function for complex number in C++

  • Last Updated : 01 Sep, 2021

The cosh() function for complex number is defined in the complex header file.This function is the complex version of the cosh() function. This function is used to calculate the complex hyperbolic cosine of complex number z and returns the cosh of complex number z.

Syntax:

cosh(z);

Parameter:

  • z: This method takes a mandatory parameter z which represents the complex number.

Return value: This function returns the cosh() of complex number z.

Below programs illustrate the cosh() function in C++:



PROGRAM 1:-

Output:

The cosh of (0, 1) is (0.540302, 0)

Example 2:-




  
// c++ program to demonstrate
// example of cosh() function.
  
  
#include <bits/stdc++.h>
using namespace std;
  
// driver program
int main ()
{
  complex<double> complexnumber (1.0, 0.0);
  
  
  // use of cosh() function for complex number
  cout << "The cosh of " << complexnumber << " is "
                     << cosh(complexnumber) << endl;
  
  
  return 0;
}

Output:

The cosh of (1, 0) is (1.54308, 0)
Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for the language and STL. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :