當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C++ Math acosh()用法及代碼示例

該函數計算以弧度給出的角度的弧雙曲餘弦。

其中,弧雙曲餘弦是雙曲餘弦的逆運算。

高價-1x = acosh(x);

用法

假設角度為 'x':

float acosh(float x);
double acosh(double x);
long double acosh(long double x);
double acosh(integral x);

參數

x: 要計算其反雙曲餘弦的值。

返回值

它返回 x 的反雙曲餘弦值。

例子1

讓我們看一個簡單的例子,當 degree 的值是整數類型時。

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    int degree =30;
    float x = degree*3.14/180;
    std::cout << "Value of degree is:" <<degree<< std::endl;
    cout<<"cosh(x):"<<cosh(x)<<'\n';
    cout<<"acosh(x):"<<acosh(x);
    return 0;
}

輸出:

Value of degree is:30
cosh(x):1.14009
acosh(x):-nan   

在本例中,acosh() 函數計算 x 的反雙曲餘弦並返回值 -nan。

例子2

讓我們看一個簡單的例子,當 degree 的值是 float 類型時。

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    int degree =15.7;
    float x = degree*3.14/180;
    std::cout << "Value of degree is:" <<degree<< std::endl;
    cout<<"cosh(x):"<<cosh(x)<<'\n';
    cout<<"acosh(x):"<<acosh(x);
    return 0;
}

輸出:

Value of degree is:15.7
cosh(x):1.03443
acosh(x):-nan   

在此示例中,acosh() 計算 x 的反雙曲餘弦並返回值 -nan。






相關用法


注:本文由純淨天空篩選整理自 C++ Math acosh()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。