java.lang.Math.tanh() 用於返回值的雙曲正切值。任何值 x 的雙曲正切都可以定義為 ((ex-e-x)/2)/((ex+ e-x)/2),其中 e 是歐拉數。我們可以說tanh(a) = sinh(a)/cosh(a)。
用法
public static double tanh(double x)
參數
x = the number whose hyperbolic tangent is to be returned.
返回
It returns the hyperbolic tangent of x.
- 如果參數為正數或負數,此方法將返回雙曲正切值。
- 如果參數為零,則此方法將返回與參數相同符號的零。
- 如果參數為 NaN,則此方法將返回 NaN。
- 如果參數是 Positive Infinity,則此方法將返回 +1.0。
- 如果參數為 Negative Infinity,則此方法將返回 -1.0。
例子1
public class TanhExample1
{
public static void main(String[] args)
{
double a = 12.0;
System.out.println(Math.tanh(a));
}
}
輸出:
0.9999999999244973
例子2
public class TanhExample2
{
public static void main(String[] args)
{
double a = 60.0;
System.out.println(Math.tanh(a));
}
}
輸出:
1.0
例子3
public class TanhExample3
{
public static void main(String[] args)
{
double a = -0.0;
// Input negative zero, Output negative zero
System.out.println(Math.tanh(a));
}
}
輸出:
-0.0
示例 4
public class TanhExample4
{
public static void main(String[] args)
{
double a = 0.0/0;
// Input NaN, Output NaN
System.out.println(Math.tanh(a));
}
}
輸出:
NaN
例 5
public class TanhExample5
{
public static void main(String[] args)
{
double a = -1.0/0;
// Input negative infinity, Output negative 1
System.out.println(Math.tanh(a));
}
}
輸出:
-1.0
相關用法
- Java Math.tan()用法及代碼示例
- Java Math.toDegrees()用法及代碼示例
- Java Math.toIntExact()用法及代碼示例
- Java Math.toRadians()用法及代碼示例
- Java Math.multiplyExact()用法及代碼示例
- Java Math.rint()用法及代碼示例
- Java Math.nextUp()用法及代碼示例
- Java Math.asin()用法及代碼示例
- Java Math.atan()用法及代碼示例
- Java Math.nextAfter()用法及代碼示例
- Java Math.exp()用法及代碼示例
- Java Math.getExponent()用法及代碼示例
- Java Math.IEEEremainder()用法及代碼示例
- Java Math.sqrt()用法及代碼示例
- Java Math.incrementExact()用法及代碼示例
- Java Math.min()用法及代碼示例
- Java Math.log()用法及代碼示例
- Java Math.log1p()用法及代碼示例
- Java Math.signum()用法及代碼示例
- Java Math.copySign()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Math.tanh() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。