What is the acosh() function in C++?

Overview

The acosh() function is used to return the inverse hyperbolic cosine in radians of the argument x passed to it.

Note: The arc hyperbolic cosine is the same as the inverse hyperbolic cosine.

Mathematically, this function is given by:

acosh(x) = acosh1acosh^{-1}x

Syntax

double acosh(double x);
float  acosh(float x);
long double acosh(long double x);

Parameters

This function takes x as the only and mandatory parameter value.

The value of this parameter must be equal to or greater than 1. When the value passed is less than 1, a domain error is returned.

Return value

The returned value is the arc hyperbolic cosine of the argument x.

Example

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
// creating variables
int x = 10;
double result;
// implementing the acosh
result = acosh(x);
cout << "acosh(10) = " << result << " radian" << endl;
return 0;
}

Explanation

  • Line 8 and 9: We create the variables x and result.

  • Line 12: We implement the acosh() function on the value of x and assign it to the variable result.

  • Line 13: We print the result variable.