C++ std::asinh() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
<cmath>

Definition

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
CallWhat 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

ParameterDescription
xRequired. Any number, positive, negative, or zero. An integer is converted to double.

Return Value

Return ValueDescription
Inverse sinhThe number whose hyperbolic sine is x, with the same sign as x.
0asinh(0) is exactly 0.
inf / -infReturned 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;
}

How It Works

  1. The loop passes each value to std::asinh(). There is no restriction on the input.
  2. asinh(0) is 0, and asinh(1) is 0.881374. The function is odd, so asinh(-1) is -0.881374.
  3. The curve flattens out. asinh(10) is only 2.99822, which shows that it grows like a logarithm.

Example 2 — Undo sinh()

Apply sinh() and then asinh(). You should get the original number back.

C++
#include <cmath>
#include <iostream>

int main() {
    for (double x : {0.75, 2.0}) {
        double y = std::sinh(x);
        std::cout << "sinh(" << x << ") = " << y
                  << ", asinh back = " << std::asinh(y) << '\n';
    }
    return 0;
}

How It Works

  1. The variable y keeps the result of sinh(x) so it can be passed to asinh() next.
  2. For 0.75 the sinh is 0.822317, and asinh() of that gives 0.75 back.
  3. For 2 the sinh is 3.62686, and asinh() returns exactly 2. The two functions cancel each other.

Example 3 — Why Not Use the Formula

Compare log(x + sqrt(x * x + 1)) with std::asinh() for a large negative number.

C++
#include <cmath>
#include <iostream>

int main() {
    double x = -1e8;

    double byFormula = std::log(x + std::sqrt(x * x + 1.0));
    double byLibrary = std::asinh(x);

    std::cout << "formula: " << byFormula << '\n';
    std::cout << "asinh:   " << byLibrary << '\n';
    return 0;
}

How It Works

  1. x * x + 1.0 is 1e16 + 1, which a double rounds to 1e16. The square root is exactly 1e8.
  2. Then x + 1e8 is -1e8 + 1e8, which is 0. The log of 0 is -inf, so the formula fails.
  3. 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.

Next: atan()

Keep going through the <cmath> functions. Inverse tangent, as an angle in radians.

atan() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful