C acosh() Function

Definition
In C, acosh() returns the inverse hyperbolic cosine of x. acosh(1) is 0. Larger inputs give a larger result.
You pass one double, and it must be 1 or greater. The result is a double that is 0 or greater. Include <math.h>.
Syntax
Pass a value of 1 or more. Start with this call.
| Call | What it does |
|---|
acosh(1.0) | Returns 0, the smallest result this function gives. |
Include <math.h>. On GCC, link with -lm.
Library declarations
double acosh(double x);
float acoshf(float x);
long double acoshl(long double x);
Parameters
| Parameter | Description |
|---|
| x | Required. A double that is 1 or greater. |
Return Value
| Return Value | Description |
|---|
| Inverse hyperbolic cosine | A double that is 0 or greater. |
| NaN | Returned when x is less than 1. |
C Examples
Example 1 — Common acosh Values
Print results for the endpoint 1 and a larger input.
#include <math.h>
#include <stdio.h>
int main(void) {
printf("acosh(1) = %.5f\n", acosh(1.0));
printf("acosh(2) = %.5f\n", acosh(2.0));
return 0;
}
acosh(1) = 0.00000
acosh(2) = 1.31696
How It Works
- Include math.h. Declares
acosh; link with -lm on GCC. - Endpoint.
acosh(1) is 0 because cosh(0) = 1. - Larger x.
acosh(2) ≈ 1.31696. - Always ≥ 0. The principal value is non-negative.
Example 2 — Verify with cosh
Round-trip a value: acosh then cosh should recover the original x.
#include <math.h>
#include <stdio.h>
int main(void) {
double x = 2.5;
double t = acosh(x);
printf("acosh(%.1f) = %.5f\n", x, t);
printf("cosh(t) = %.5f\n", cosh(t));
return 0;
}
acosh(2.5) = 1.56680
cosh(t) = 2.50000
How It Works
- Start with x ≥ 1.
2.5 is in the domain. - Invert with acosh. You get the hyperbolic angle
t. - Apply cosh.
cosh(t) returns to 2.5. - Use as a check. Great for testing and understanding the inverse pair.
Example 3 — Match the Log Formula
Compare the library result with ln(x + sqrt(x*x - 1)) using log and sqrt.
#include <math.h>
#include <stdio.h>
int main(void) {
double x = 2.0;
double lib = acosh(x);
double hand = log(x + sqrt(x * x - 1.0));
printf("acosh(2) = %.10f\n", lib);
printf("ln formula = %.10f\n", hand);
return 0;
}
How It Works
- Library call.
acosh(2) uses a carefully coded implementation. - Hand formula.
log + sqrt express the same math identity. - They agree. For this value the digits match closely.
- Prefer acosh. The dedicated function is clearer and usually more robust near the domain edge.
Frequently Asked Questions
acosh() returns the inverse hyperbolic cosine of x. acosh(1) is 0.
x is required. It is a double that must be 1 or greater.
A double that is 0 or greater. If x is less than 1, the result is NaN.
Include <math.h>. On GCC, link with -lm.
No. Values below 1 are outside the domain, and the result is NaN.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful