The acosh() function defined in the math.h header file. It helps to return the arc hyperbolic cosine value of the given number in radians. The arc hyperbolic cosine means inverse hyperbolic cosine value.
double acosh(double x); #where x can be in int, float or long double
Also, two functions acoshf() and acoshl() were used with type float and long double respectively.
float acoshf(float x);
long double acoshl(long double x);
The acosh() function takes a single parameter in the range x ≥ 1. Using cast operator we can explicitly convert the type to double to find the arc hyperbolic cosine of type int, float, or long double.
Parameter | Description | Required / Optional |
---|---|---|
double value | A double value greater than or equal to 1 (x ≥ 1) | Required |
The return value of acosh() function is a number greater than or equal to 0 in radians.
Input | Return Value |
---|---|
x ≥ 1 | a number greater than or equal to 0 |
x < 1 | NaN (not a number) |
#include <stdio.h>
#include <math.h>
int main()
{
const double PI = 3.1415926;
double v, output;
v = 5.9;
output = acosh(v);
printf("The acosh(%.2f) = %.2lf in radians\n", v, output);
//radians to degree convertion
output = acosh(v)*180/PI;
printf("The acosh(%.2f) = %.2lf in degrees\n", v, output);
// paramter not in range
v = 0.5;
output = acosh(v);
printf("The acosh(%.2f) = %.2lf", v, output);
return 0;
}
Output:
The acosh(5.90) = 2.46 in radians The acosh(5.90) = 141.00 in degrees The acosh(0.50) = nan
#include <stdio.h>
#include <math.h>
int main()
{
float f, fcosx;
long double l, lcosx;
// type float
f = 5.5054;
fcosx = acoshf(f);
//type long double
l = 5.50540593;
lcosx = acoshl(l);
printf("acoshf(x) is equal to %f in radians\n", fcosx);
printf("acoshl(x) is equal to %Lf in radians", lcosx);
return 0;
}
Output:
acoshf(x) is equal to 2.390524 in radians acoshl(x) is equal to 2.390525 in radians