獲取 Java 中給定值的雙曲餘弦


為了獲得 Java 中給定值的雙曲餘弦,我們使用 java.lang.Math.cosh() 方法。cosh() 方法接受一個弧度的引數,並返回作為角度的引數的雙曲餘弦。

宣告 - java.lang.Math.cosh() 宣告如下 -

public static double cosh(double x)

其中 x 為弧度角度。

讓我們看一下一個程式,該程式在 Java 中獲取給定值的雙曲餘弦。

示例

 線上演示

import java.lang.Math;
public class Example {
   public static void main(String[] args) {
      // get two double numbers in degrees
      double x = 90;
      double y = 180;
      // convert them in radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);
      // computing and displaying the hyperbolic cosine of these doubles
      System.out.println("Hyperbolic cosine of " + x + " = " + Math.cosh(x));
      System.out.println("Hyperbolic cosine of " + y + " = " + Math.cosh(y));
   }
}

輸出

Hyperbolic cosine of 1.5707963267948966 = 2.5091784786580567
Hyperbolic cosine of 3.141592653589793 = 11.591953275521519

更新於: 26-Jun-2020

152 次瀏覽

開啟你的 職業生涯

完成該課程並獲得認證

開始
廣告