Java Math cosh()方法及其示例

这个 JAVA朗,数学。cosh() 返回作为参数传递给它的双精度值的双曲余弦。任意值的双曲余弦 A. 定义为,

null

(e) A. +e -a )/2

其中e是欧拉数。

如果参数为NaN,则结果为NaN。如果参数为无穷大,则结果为正无穷大。如果参数为零,则结果为一。

语法:

public static double cosh(double a)
Parameter : 
a : the value whose hyperbolic cosine is to be returned.

返回: 此方法返回参数的双曲余弦值。

例1: 表示工作 JAVA朗,数学。cosh() 方法

// Java program to demonstrate working
// of java.lang.Math.cosh() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
double a = 3.5 ;
System.out.println(Math.cosh(a));
a = 90.328 ;
System.out.println(Math.cosh(a));
}
}


输出:

16.572824671057315
8.470751974588509E38

例2: 表示工作 JAVA朗,数学。cosh() 参数为NaN或无穷大时的方法。

// Java program to demonstrate working
// of java.lang.Math.cosh() method infinity case
import java.lang.Math;
public class GFG {
public static void main(String[] args)
{
double positiveInfinity =
Double.POSITIVE_INFINITY;
double negativeInfinity =
Double.NEGATIVE_INFINITY;
double nan = Double.NaN;
double result;
// Here argument is negative infinity
result = Math.cosh(negativeInfinity);
System.out.println(result);
// Here argument is positive infinity
result = Math.cosh(positiveInfinity);
System.out.println(result);
// Here argument is NaN, output will be NaN
result = Math.cosh(nan);
System.out.println(result);
}
}


输出:

Infinity
Infinity
NaN

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享