Java - StrictMath cosh(double) 方法



描述

Java StrictMath cosh(double a) 方法返回双精度值的双曲余弦。特殊情况

  • 如果参数是 NaN,则结果是 NaN。

  • 如果参数是无限大,则结果是正无穷大。

  • 如果参数是零,则结果是 1.0。

计算结果必须在精确结果的 2.5 ulps 以内。

声明

以下是 java.lang.StrictMath.cosh() 方法的声明

public static double cosh(double x)

参数

x − 要返回其双曲余弦的数字。

返回值

此方法返回 x 的双曲余弦。

异常

获取角度的双曲余弦示例

以下示例演示了 StrictMath cosh() 方法的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to PI/2
      double x = StrictMath.PI / 2;

      // convert x to radians
      x = StrictMath.toRadians(x);

      // get the hyperbolic cosine of x
      System.out.println("StrictMath.cosh(" + x + ")=" + StrictMath.cosh(x));
   }
}

输出

让我们编译并运行上面的程序,这将产生以下结果:

StrictMath.cosh(0.027415567780803774)=1.0003758302174048

获取0°角的双曲余弦示例

以下示例演示了 StrictMath cosh() 方法在0°角的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to zero
      double x = 0.0d;

      // convert x to radians
      x = StrictMath.toRadians(x);

      // get the hyperbolic cosine of x
      System.out.println("StrictMath.cos(" + x + ")=" + StrictMath.cosh(x));
   }
}

输出

让我们编译并运行上面的程序,这将产生以下结果:

StrictMath.cos(0.0)=1.0

获取45°角的双曲余弦示例

以下示例演示了 StrictMath cosh() 方法在45°角的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to zero
      double x = 45.0d;

      // convert x to radians
      x = StrictMath.toRadians(x);

      // get the hyperbolic cosine of x
      System.out.println("StrictMath.cosh(" + x + ")=" + StrictMath.cosh(x));
   }
}

输出

让我们编译并运行上面的程序,这将产生以下结果:

StrictMath.cosh(0.7853981633974483)=1.3246090892520057
java_lang_strictmath.htm
广告
© . All rights reserved.