acosh() function in C++ STL

The acosh() is an inbuilt function in C++ STL which returns the inverse hyperbolic cosine of an angle given in radians.

Syntax:

acosh(data_type x)

Parameter :The function accepts one mandatory parameter x which specifies the inverse hyperbolic angle in radian which should be greater or equal to 1. If the argument is less than 1, -nan is returned. The parameter can be of double, float or long double datatype.



Return : The acosh() function returns the inverse hyperbolic sine of the argument in radians which is in the range [0, inf].

Below programs illustrate the above approach:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to demonstrate
// the acosh() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    double x = 50.0;
  
    // Function call to calculate acosh(x) value
    double result = acosh(x);
  
    cout << "acosh(50.0) = " << result << " radians" << endl;
    cout << "acosh(50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}

chevron_right


Output:

acosh(50.0) = 4.60507 radians
acosh(50.0) = 263.851 degrees

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to demonstrate
// the acosh() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    int x = 40.0;
  
    // Function call to calculate acosh(x) value
    double result = acosh(x);
  
    cout << "acosh(40.0) = " << result << " radians" << endl;
    cout << "acosh(40.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}

chevron_right


Output:

acosh(40.0) = 4.38187 radians
acosh(40.0) = 251.063 degrees

Errors and Exceptions: The function returns no matching function for call to error when a string or a character is passed as an argument.

Program 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to demonstrate
// the acosh() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    string x = "gfg";
  
    // Function call to calculate acosh(x) value
    double result = acosh(x);
  
    cout << "acosh(50.0) = " << result << " radians" << endl;
    cout << "acosh(50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}

chevron_right


Output:

prog.cpp:11:25: error: no matching function for call to 'acosh(std::__cxx11::string&)'
  double result = acosh(x);

Program 4:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to demonstrate
// the acosh() function
// value less than 1
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    double x = -50.0;
  
    // Function call to calculate acosh(x) value
    double result = acosh(x);
  
    cout << "acosh(-50.0) = " << result << " radians" << endl;
    cout << "acosh(-50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}

chevron_right


Output:

acosh(-50.0) = -nan radians
acosh(-50.0) = -nan degrees


My Personal Notes arrow_drop_up

pawanasipugmailcom

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.