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


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

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

數學上

cosx = ex+ e-x/2

用法

假設雙曲角為 'x':

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

參數

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

返回值

它返回以弧度給出的角度的雙曲餘弦值。

例子1

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

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

輸出:

Value of degree is:45
cosh(radian):1.32426 

在此示例中,cosh() 計算角度 45 的雙曲餘弦值並返回值 1.324。

例子2

讓我們看另一個簡單的例子。

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

輸出:

Value of degree is:25.5
cosh(radian):1.10058   





相關用法


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