- C 標準庫
- C 庫 - 首頁
- C 庫 - <assert.h>
- C 庫 - <complex.h>
- C 庫 - <ctype.h>
- C 庫 - <errno.h>
- C 庫 - <fenv.h>
- C 庫 - <float.h>
- C 庫 - <inttypes.h>
- C 庫 - <iso646.h>
- C 庫 - <limits.h>
- C 庫 - <locale.h>
- C 庫 - <math.h>
- C 庫 - <setjmp.h>
- C 庫 - <signal.h>
- C 庫 - <stdalign.h>
- C 庫 - <stdarg.h>
- C 庫 - <stdbool.h>
- C 庫 - <stddef.h>
- C 庫 - <stdio.h>
- C 庫 - <stdlib.h>
- C 庫 - <string.h>
- C 庫 - <tgmath.h>
- C 庫 - <time.h>
- C 庫 - <wctype.h>
- C 標準庫資源
- C 庫 - 快速指南
- C 庫 - 有用資源
- C 庫 - 討論
- C 程式設計資源
- C 程式設計 - 教程
- C - 有用資源
C 庫 - cosh() 函式
C 庫的 cosh() 函式,型別為 double,接受引數 (x),返回 x 的雙曲餘弦值。在程式中,它用於表示幾何圖形的角度。
雙曲餘弦在工程物理學中使用,因為它出現在溫度成型時金屬棒的熱方程的解中。
語法
以下是 C 庫函式 cosh() 的語法 -
double cosh(double x)
引數
此函式僅接受一個引數。
x - 這是一個浮點值。
返回值
此函式返回 x 的雙曲餘弦值。
示例 1
以下是一個基本的 C 庫程式,演示了 cosh() 函式的使用。
#include <stdio.h>
#include <math.h>
int main () {
double x;
x = 0.5;
printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x));
x = 1.0;
printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x));
x = 1.5;
printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x));
return(0);
}
輸出
以上程式碼產生以下結果 -
The hyperbolic cosine of 0.500000 is 1.127626 The hyperbolic cosine of 1.000000 is 1.543081 The hyperbolic cosine of 1.500000 is 2.352410
示例 2
我們在 for 迴圈中使用 cosh(),它生成一系列正數的雙曲餘弦值表。
#include <stdio.h>
#include <math.h>
int main() {
printf("Table of Hyperbolic Cosines:\n");
for (double x = 0.0; x <= 1.5; x += 0.5) {
double res = cosh(x);
printf("cosh(%.2lf) = %.6lf\n", x, res);
}
return 0;
}
輸出
執行以上程式碼後,我們得到以下結果 -
Table of Hyperbolic Cosines: cosh(0.00) = 1.000000 cosh(0.50) = 1.127626 cosh(1.00) = 1.543081 cosh(1.50) = 2.352410
示例 3
下面的程式使用 cosh() 函式查詢實數的雙曲餘弦值。
#include <stdio.h>
#include <math.h>
int main() {
double x = 0.5;
double result = cosh(x);
printf("Hyperbolic cosine of %.2lf (in radians) = %.6lf\n", x, result);
return 0;
}
輸出
執行程式碼後,我們得到以下結果 -
Hyperbolic cosine of 0.50 (in radians) = 1.127626
廣告