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


C語言 tanh用法及代碼示例

C語言math頭文件(math.h)中tanh函數的用法及代碼示例。

用法:

     double tanh  (double x);
      float tanhf (float x);
long double tanhl (long double x);
     double tanh (double x);
      float tanh (float x);
long double tanh (long double x);
     double tanh (T x);           // additional overloads for integral types
計算雙曲正切
返回的雙曲正切值x

標頭<tgmath.h>提供此函數的type-generic宏版本。
這個函數重載於<complex><valarray>(參考複雜的tanhvalarray tanh)。
額外的過載在此頭文件中提供(<cmath>) 為了整數類型:這些重載有效地轉換x到一個double計算之前(為T有任何整數類型)。

這個函數也重載於<complex><valarray>(參考複雜的tanhvalarray tanh)。

參數

x
表示雙曲角的值。

返回值

的雙曲正切x

示例

/* tanh example */
#include <stdio.h>      /* printf */
#include <math.h>       /* tanh, log */

int main ()
{
  double param, result;
  param = log(2.0);
  result = tanh (param);
  printf ("The hyperbolic tangent of %f is %f.\n", param, result);
  return 0;
}


輸出:

The hyperbolic tangent of 0.693147 is 0.600000.

相關用法


注:本文由純淨天空篩選整理自C標準庫大神的英文原創作品 C tanh function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。