Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

asinh() function in C++ STL

  • Last Updated : 29 Nov, 2021

The asinh() is an inbuilt function in C++ STL that returns the inverse hyperbolic sine of an angle given in radians. The function belongs to <cmath> header file.

Syntax: 

asinh(data_type x)

Parameter: The function accepts one mandatory parameter x which specifies the inverse hyperbolic angle in radian. It can be any value i.e. negative, positive, or zero. The parameter can be of double, float, or long double datatype. 

Return Value: This function returns the inverse hyperbolic sine of the argument in radians.

According to C++ 11 standard, there are various prototypes available for asinh() function:

DatatypePrototype
For int double asinh(T val); 
For floatfloat asinh(float val);
For doubledouble asinh(double val);
For long doublelong double asinh(long double val);

Here, val is the variable.

Example 1: 

CPP




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

Example 2: 

CPP




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

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

CPP




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

Error:

prog.cpp: In function ‘int main()’:
prog.cpp:12:28: error: no matching function for call to ‘asinh(std::__cxx11::string&)’
     double result = asinh(x);

The above program generates an error of no matching function for call as a string is passed as an argument. 

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!