# acosh() function in C++ STL

The acosh() is an inbuilt function in C++ STL which returns the inverse hyperbolic cosine of an angle given in radians.

Syntax:

acosh(data_type x)

Parameter :The function accepts one mandatory parameter x which specifies the inverse hyperbolic angle in radian which should be greater or equal to 1. If the argument is less than 1, -nan is returned. The parameter can be of double, float or long double datatype.

Return : The acosh() function returns the inverse hyperbolic sine of the argument in radians which is in the range [0, inf].

Below programs illustrate the above approach:

Program 1:

 // C++ program to demonstrate // the acosh() function #include using namespace std;    int main() {     double x = 50.0;        // Function call to calculate acosh(x) value     double result = acosh(x);        cout << "acosh(50.0) = " << result << " radians" << endl;     cout << "acosh(50.0) = " << result * 180 / 3.141592          << " degrees" << endl;     return 0; }

/div>
Output:

acosh(50.0) = 263.851 degrees

Program 2:

 // C++ program to demonstrate // the acosh() function #include using namespace std;    int main() {     int x = 40.0;        // Function call to calculate acosh(x) value     double result = acosh(x);        cout << "acosh(40.0) = " << result << " radians" << endl;     cout << "acosh(40.0) = " << result * 180 / 3.141592          << " degrees" << endl;     return 0; }

Output:

acosh(40.0) = 251.063 degrees

Errors and Exceptions: The function returns no matching function for call to error when a string or a character is passed as an argument.

Program 3:

 // C++ program to demonstrate // the acosh() function #include using namespace std;    int main() {     string x = "gfg";        // Function call to calculate acosh(x) value     double result = acosh(x);        cout << "acosh(50.0) = " << result << " radians" << endl;     cout << "acosh(50.0) = " << result * 180 / 3.141592          << " degrees" << endl;     return 0; }

Output:

prog.cpp:11:25: error: no matching function for call to 'acosh(std::__cxx11::string&)'
double result = acosh(x);

Program 4:

 // C++ program to demonstrate // the acosh() function // value less than 1 #include using namespace std;    int main() {     double x = -50.0;        // Function call to calculate acosh(x) value     double result = acosh(x);        cout << "acosh(-50.0) = " << result << " radians" << endl;     cout << "acosh(-50.0) = " << result * 180 / 3.141592          << " degrees" << endl;     return 0; }

Output:

acosh(-50.0) = -nan degrees

## tags:

C++ CPP-Functions cpp-math STL STL CPP