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
廣告