acosh()函数acosh()函数是cmath标头的库函数,用于查找给定值的非负区域双曲余弦,它接受数字(x)并返回x的非负区域双曲余弦。
注意: x的值不应小于1,如果参数小于0,则会返回域错误(-nan)。
acosh()函数语法:
acosh(x);
参数: x –是计算其非负面积双曲余弦的数字/值。
返回值: double-返回double类型值,它是给定数字/值x的非负区域双曲余弦值。
示例
Input: float x = 2.45; Function call: acosh(x); Output: 1.54471
acosh()函数示例//示例 
// acosh()功能
#include <iostream>
#include <cmath>
using namespace std;
// main()部分
int main(){
    float x;
    
    x = 1.0;
    cout<<"acosh("<<x<<"): "<<acosh(x)<<endl;
    x = 10.23;
    cout<<"acosh("<<x<<"): "<<acosh(x)<<endl;    
    x = 2.45;
    cout<<"acosh("<<x<<"): "<<acosh(x)<<endl;    
    
    return 0;
}输出结果
acosh(1): 0 acosh(10.23): 3.01607 acosh(2.45): 1.54471
域错误示例
如果提供的值小于1,则返回-nan。
//示例 
// acosh()功能
#include <iostream>
#include <cmath>
using namespace std;
// main()部分
int main(){
    float x;
    
    //此输入值没有错误
    x = 1.0;
    cout<<"acosh("<<x<<"): "<<acosh(x)<<endl;
    //输入值出现域错误
    x = 0.25;
    cout<<"acosh("<<x<<"): "<<acosh(x)<<endl;    
    return 0;
}输出结果
acosh(1): 0 acosh(0.25): -nan
参考:C ++acosh()函数