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


PHP tanh()用法及代碼示例

PHP tanh() 函數是預定義的三角數學函數。它用於返回數字的雙曲正切值。它等於 sinh(x)/cos(x)。

用法:

float cosh ( float $arg );
參數 描述 必需/可選
arg 指定參數 Required

例子1

<?php
  $n=4;
  echo "Your number is:".$n;
  echo "<br>"."By using 'tanh()' function your value is:".tanh($n)."<br>";
?>

輸出:

Your number is:4
By using 'tanh()' function your value is:0.99932929973907

例子2

<?php
  $n=(-4);
  echo "Your number is:".$n;
  echo "<br>"."By using 'tanh()' function your value is:".tanh($n)."<br>";
?>

輸出:

Your number is:-4
By using 'tanh()' function your value is:-0.99932929973907

例子3

<?php
  $n=(0.50);
  echo "Your number is:".$n;
  echo "<br>"."By using 'tanh()' function your value is:".tanh($n)."<br>";
?>

輸出:

Your number is:0.5
By using 'tanh()' function your value is:0.46211715726001

示例 4

<?php
  $n=(-0.50);
  echo "Your number is:".$n;
  echo "<br>"."By using 'tanh()' function your value is:".tanh($n)."<br>";
?>

輸出:

Your number is:-0.5
By using 'tanh()' function your value is:-0.46211715726001

例 5

<?php
  $n=(M_PI_4);
  echo "Your number is:M_PI_4";
  echo "<br>"."By using 'tanh()' function your value is:".tanh($n)."<br>";
?>

輸出:

Your number is:M_PI_4
By using 'tanh()' function your value is:0.65579420263267






相關用法


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