In C++, std::asinh(x) is the inverse hyperbolic sine. It undoes std::sinh(). If sinh(2) is 3.62686, then asinh(3.62686) gives back 2.
The input can be any number, so there is no domain problem. Its formula is log(x + sqrt(x * x + 1)), but asinh() is safer because the formula loses accuracy for large negative x. It was added in C++11.
std::asinh() is declared in <cmath> and is part of the group Hyperbolic functions. Hyperbolic functions are built from ex. They are not about angles, but they have the same names with an h added.
Syntax
Include <cmath> and call std::asinh. Start with these lines.
C++
double a = std::asinh(1.0); // double version
float b = std::asinh(1.0f); // float version
Call
What it does
std::asinh(1.0)
Passes a double and returns a double. Here the result is 0.881374.
std::asinh(1.0f)
Passes a float, so the float overload runs and returns a float.
std::asinh(0)
An integer is converted to double. Returns 0 as a double.
Write std::asinh so the C++ overloads for float, double, and long double are used.
Library declarations
C++
float asinh(float x);
double asinh(double x);
long double asinh(long double x);
double asinh(Integer x); // for integer types
Parameters
Parameter
Description
x
Required. Any number, positive, negative, or zero. An integer is converted to double.
Return Value
Return Value
Description
Inverse sinh
The number whose hyperbolic sine is x, with the same sign as x.
0
asinh(0) is exactly 0.
inf / -inf
Returned for inf and -inf.
C++ Examples
Example 1 — Inverse Hyperbolic Sine of Common Values
Print asinh() for a few numbers, including a negative one and a big one.
C++
#include <cmath>
#include <iostream>
int main() {
double values[] = {0.0, 1.0, -1.0, 10.0};
for (double v : values) {
std::cout << "asinh(" << v << ") = " << std::asinh(v) << '\n';
}
return 0;
}
x * x + 1.0 is 1e16 + 1, which a double rounds to 1e16. The square root is exactly 1e8.
Then x + 1e8 is -1e8 + 1e8, which is 0. The log of 0 is -inf, so the formula fails.
std::asinh(-1e8) uses a better method and gives the correct -19.1138. Always prefer the library function.
Frequently Asked Questions
std::asinh(x) returns the inverse hyperbolic sine of x. It is the number whose sinh is x. It works for any real number.
The inverse hyperbolic sine as float, double, or long double. asinh(0) is 0, and the result has the same sign as x.
They are opposites. sinh(x) turns a number into its hyperbolic sine, and asinh(y) finds the x whose sinh is y. asinh(sinh(x)) gives back x.
No. Unlike asin(), asinh() accepts any real number and always returns a real number.
Include <cmath> and write std::asinh(). That always works and picks the C++ overloads. The global name ::asinh often works too, but the standard does not promise it, and it may only take a double.