acosh()是C++ STL中的內置函數,它返回以弧度給出的角度的反雙曲餘弦值。
用法:
acosh(data_type x)
參數:該函數接受一個強製性參數x,該參數指定弧度中的雙曲反角應大於或等於1。如果參數小於1,則返回-nan。該參數可以是double,float或long double數據類型。
返回:acosh()函數以弧度返回參數的反雙曲餘弦值,其範圍為[0,inf]。
以下示例程序旨在說明上述方法:
示例1:
// 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;
}
輸出:
acosh(50.0) = 4.60507 radians acosh(50.0) = 263.851 degrees
示例2:
// 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;
}
輸出:
acosh(40.0) = 4.38187 radians acosh(40.0) = 251.063 degrees
錯誤和異常:當將字符串或字符作為參數傳遞時,該函數不返回任何匹配函數來調用錯誤。
示例3:
// 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;
}
輸出:
prog.cpp:11:25: error: no matching function for call to 'acosh(std::__cxx11::string&)' double result = acosh(x);
示例4:
// 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;
}
輸出:
acosh(-50.0) = -nan radians acosh(-50.0) = -nan degrees
相關用法
- C++ complex acosh()用法及代碼示例
- C++ div()用法及代碼示例
- C++ log()用法及代碼示例
- C++ fma()用法及代碼示例
- C++ regex_iterator()用法及代碼示例
- C++ imag()用法及代碼示例
- C++ real()用法及代碼示例
- C++ valarray abs()用法及代碼示例
- C++ valarray sin()用法及代碼示例
- C++ valarray end()用法及代碼示例
- C++ map rbegin()用法及代碼示例
- C++ map rbegin()用法及代碼示例
注:本文由純淨天空篩選整理自pawan_asipu大神的英文原創作品 acosh() function in C++ STL。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。