In this C++ tutorial, you will learn how to find the inverse hyperbolic cosine of a number using acosh() function of cmath, with syntax and examples.
C++ acosh()
C++ acosh() returns arc (inverse) hyperbolic cosine of a number in radians.
Syntax
The syntax of C++ acosh() is
acosh(x)
where
Parameter | Description |
---|---|
x | A double, float, or long double value. The value of x must lie in the range [1, infinity). |
Returns
The return value depends on the type of value passed for parameter x.
The return value of acosh(x) is
- double if x is double.
- float if x is float.
- long double if x is long double.
The synopsis of acosh() function is
double acosh(double x);
float acosh(float x);
long double acosh(long double x);
double acosh(T x); // For integral type
acosh() is a function of cmath library. Include cmath library at start of the program, if using acosh() function.
Example
In this example, we read a number from user into variable x, and find its inverse hyperbolic cosine value using acosh().
C++ Program
#include <iostream>
#include<cmath>
using namespace std;
int main() {
double x;
cout << "Enter a number : ";
cin >> x;
double result = acosh(x);
cout << "acosh(" << x << ") : " << result << " radians" << endl;
}
Output
Enter a number : 1
acosh(1) : 0 radians
Program ended with exit code: 0
Enter a number : 25
acosh(25) : 3.91162 radians
Program ended with exit code: 0
Enter a number : 0
acosh(0) : nan radians
Program ended with exit code: 0
Conclusion
In this C++ Tutorial, we learned the syntax of C++ acosh(), and how to use this function to find the inverse hyperbolic cosine of given value, with the help of examples.