Java.lang.StrictMath.cosh() 方法
描述
java.lang.StrictMath.cosh() 方法返回 double 值的双曲余弦值。 x 的双曲余弦定义为 (ex + e-x)/2 其中 e 为 欧拉数。包括这些情况 −
- 如果参数为 NaN,则结果为 NaN。
- 如果参数是无限的,那么结果是正无穷大。
- 如果参数为零,则结果为 1.0。
声明
以下是 java.lang.StrictMath.cosh() 方法的声明。
public static double cosh(double x)
参数
x − 这是要返回其双曲余弦的数字。
返回值
此方法返回 x 的双曲余弦值。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.cosh() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
double d1 = (60*(Math.PI))/180 , d2 = 0.0, d3 = (1.0/0.0) ;
// returns the hyperbolic cosine of specified angle in radian
double coshValue = StrictMath.cosh(d1);
System.out.println("Hyperbolic cosine of d1 = " + coshValue);
coshValue = StrictMath.cosh(d2);
System.out.println("Hyperbolic cosine of d2 = " + coshValue);
coshValue = StrictMath.cosh(d3);
System.out.println("Hyperbolic cosine of d3 = " + coshValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Hyperbolic cosine of d1 = 1.600286857702386 Hyperbolic cosine of d2 = 1.0 Hyperbolic cosine of d3 = Infinity

