获取 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 次浏览

开启你的 职业生涯

完成该课程并获得认证

开始
广告
© . All rights reserved.