Math Cosh Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Cosh Function

Math Cosh Function

BLUF: Mastering Math Cosh Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Cosh Function

C++ is renowned for its efficiency. Learn how Math Cosh Function enables low-level control and high-performance computing in the tutorial below.

C++ Math cosh

The function calculates the hyperbolic cosine of an angle provided in radians.

Mathematically,

Syntax

Suppose the hyperbolic angle is 'x':

Example

float cosh(float x);
double cosh(double x);
long double cosh(long double x);
double cosh(integral x);

Parameter

x : The angle for which the hyperbolic cosine will be computed.

Return value

It calculates the hyperbolic cosine value of an angle provided in radians.

Example 1

Let's consider a basic scenario where the variable x is of integer type.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
   int x=45;
   float radian=x*3.14/180;
   std::cout << "Value of degree is :" <<x<<std::endl;
   cout<<"cosh(radian): "<<cosh(radian);
   return 0;
}

Output:

Output

Value of degree is :45
cosh(radian): 1.32426

In this instance, the cosh function calculates the hyperbolic cosine of a 45-degree angle and provides a result of 1.324.

Example 2

Let's see another simple example.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
   float x=25.5;
   float radian=x*3.14/180;
   std::cout << "Value of degree is: " << x<<std::endl;
   cout<<"cosh(radian): "<<cosh(radian);
   return 0;
}

Output:

Output

Value of degree is: 25.5
cosh(radian): 1.10058

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience