Java - Math cosh(double) 方法



描述

Java Math cosh(double a) 返回雙精度值的雙曲餘弦。特殊情況

  • 如果引數是 NaN,則結果是 NaN。

  • 如果引數是無窮大,則結果是正無窮大。

  • 如果引數是零,則結果是 1.0。

計算結果必須在精確結果的 2.5 ulps 之內。

宣告

以下是java.lang.Math.cosh() 方法的宣告

public static double cosh(double x)

引數

x − 要返回其雙曲餘弦的數字。

返回值

此方法返回 x 的雙曲餘弦。

異常

獲取角度的雙曲餘弦示例

以下示例顯示了 Math cosh() 方法的用法。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

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

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

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

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

Math.cosh(0.027415567780803774)=1.0003758302174048

獲取0°角的雙曲餘弦示例

以下示例顯示了 0° 角的 Math cosh() 方法的用法。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

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

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

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

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

Math.cos(0.0)=1.0

獲取45°角的雙曲餘弦示例

以下示例顯示了 45° 角的 Math cosh() 方法的用法。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

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

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

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

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

Math.cosh(0.7853981633974483)=1.3246090892520057
java_lang_math.htm
廣告