std::acosh

From cppreference.com
< cpp‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Exponential functions
(C++11)
(C++11)
(C++11)
(C++11)
Power functions
(C++11)
(C++11)
Trigonometric and hyperbolic functions
(C++11)
acosh
(C++11)
(C++11)
Error and gamma functions
(C++11)
(C++11)
(C++11)
(C++11)
Nearest integer floating point operations
(C++11)(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Floating point manipulation functions
(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)
(C++11)
Classification/Comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Macro constants
(C++11)(C++11)(C++11)(C++11)(C++11)
 
Defined in header <cmath>
float       acosh( float arg );
(1) (since C++11)
double      acosh( double arg );
(2) (since C++11)
long double acosh( long double arg );
(3) (since C++11)
double      acosh( Integral arg );
(4) (since C++11)

Computes the inverse hyperbolic cosine of arg.

4) A set of overloads or a function template accepting an argument of any integral type. Equivalent to 2) (the argument is cast to double).

Contents

[edit] Parameters

arg - value of a floating-point or Integral type

[edit] Return value

If no errors occur, the inverse hyperbolic cosine of arg (cosh-1
(arg)
, or arcosh(arg)) on the interval [0, +∞], is returned.

If a domain error occurs, an implementation-defined value is returned (NaN where supported)

[edit] Error handling

Errors are reported as specified in math_errhandling

If the argument is less than 1, a domain error occurs.

If the implementation supports IEEE floating-point arithmetic (IEC 60559),

  • if the argument is less than 1, FE_INVALID is raised an NaN is returned
  • if the argument is 1, +0 is returned
  • if the argument is +∞, +∞ is returned
  • if the argument is NaN, NaN is returned

[edit] Notes

Although the C standard (to which C++ refers for this function) names this function "arc hyperbolic cosine", the inverse functions of the hyperbolic functions are the area functions. Their argument is the area of a hyperbolic sector, not an arc. The correct name is "inverse hyperbolic cosine" (used by POSIX) or "area hyperbolic cosine".

[edit] Examples

#include <iostream>
#include <cmath>
#include <cfloat>
#include <cerrno>
#include <cfenv>
#include <cstring>
#pragma STDC FENV_ACCESS ON
int main()
{
    std::cout << "acosh(1) = " << std::acosh(1) << '\n'
              << "acosh(10) = " << std::acosh(10) << '\n'
              << "acosh(DBL_MAX) = " << std::acosh(DBL_MAX) << '\n'
              << "acosh(Inf) = " <<  std::acosh(INFINITY) << '\n';
     // error handling 
     errno = 0; std::feclearexcept(FE_ALL_EXCEPT);
     std::cout << "acosh(0.5) = " << std::acosh(0.5) << '\n';
     if(errno == EDOM)
         std::cout << "    errno == EDOM: " << std::strerror(errno) << '\n';
     if(std::fetestexcept(FE_INVALID))
        std::cout << "    FE_INVALID raised\n";
}

Possible output:

acosh(1) = 0
acosh(10) = 2.99322
acosh(DBL_MAX) = 710.476
acosh(Inf) = inf
acosh(0.5) = -nan
    errno == EDOM: Numerical argument out of domain
    FE_INVALID raised

[edit] See also

(C++11)
computes the inverse hyperbolic sine (arsinh(x))
(function)
(C++11)
computes the inverse hyperbolic tangent (artanh(x))
(function)
computes hyperbolic cosine (ch(x))
(function)
computes area hyperbolic cosine of a complex number
(function template)
C documentation for acosh

[edit] External links

Weisstein, Eric W. "Inverse Hyperbolic Cosine." From MathWorld--A Wolfram Web Resource.