acosh function

double acosh (double value)

Hyperbolic Area Cosine.

Implementation

double acosh(double value) {
  // acosh(x) = ln(x + sqrt(x*x - 1))
  // if |x| >= 2^28, acosh(x) ~ ln(x) + ln(2)

  if (value.abs() >= 268435456.0) // 2^28, taken from freeBSD
    return stdmath.log(value) + stdmath.log(2.0);

  return stdmath
      .log(value + (stdmath.sqrt(value - 1) * stdmath.sqrt(value + 1)));
}