log cosh_Java Math类静态double cosh(double d)与示例

本文详细介绍了 Java 中 Math 类的 cosh 方法,该方法用于计算双曲余弦值。文章解释了如何使用该方法,并提供了示例代码,展示了在不同情况下,如输入 NaN、无穷大和零时,cosh 方法的返回值。
摘要由CSDN通过智能技术生成

log cosh

数学课double cosh(double d) (Math Class double cosh(double d))

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • In this method, cosh stands for hyperbolic cosine of an angle.

    在这种方法中,cosh代表某个角度的双曲余弦。

  • This method is used to return the hyperbolic cosine of an angle of the given parameter.

    此方法用于返回给定参数角度的双曲余弦值。

  • This is a static method so it is accessible with the class name too.

    这是一个静态方法,因此也可以使用类名进行访问。

  • The return type of this method is double that means it returns the hyperbolic cosine value of the given argument.

    此方法的返回类型为double,这意味着它将返回给定参数的双曲余弦值。

  • In this method, we pass only one double type parameter as an argument (in radians) whose hyperbolic cosine is to be returned.

    在此方法中,我们仅传递一个双精度类型参数作为参数(以弧度表示),其双曲余弦值将被返回。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    public static double cosh(double d){
    }

Parameter(s): double type parameter as an argument (in radians) whose hyperbolic cosine is to be returned.

参数:双精度型参数作为参数(以弧度表示),将返回其双曲余弦值。

Return value:

返回值:

The return type of this method is double, it returns the hyperbolic cosine of an angle.

此方法的返回类型为double ,它返回角度的双曲余弦值。

Note:

注意:

  • If we pass "NaN", it returns "NaN".

    如果我们传递“ NaN”,则返回“ NaN”。

  • If we pass an infinity with any sign (positive or negative), it returns the same value.

    如果我们传递带有任何符号(正数或负数)的无穷大,它将返回相同的值。

  • If we pass zero (-0 or 0), it returns 1.0.

    如果传递零(-0或0),则返回1.0。

Java程序演示cosh(double d)方法的示例 (Java program to demonstrate example of cosh(double d) method)

// Java program to demonstrate the example of 
// cosh(double d) method of Math Class

class CoshMethod {
    public static void main(String[] args) {
        // Here we are declaring few variables
        double d1 = 7.0 / 0.0;
        double d2 = -7.0 / 0.0;
        double d3 = 0.0;
        double d4 = -0.0;
        double d5 = 60.0;

        // Display previous value of d1,d2,d3,d4 and d5
        System.out.println(" Before implementing cosh() so the value of d1 is : " + d1);
        System.out.println(" Before implementing cosh() so the value of d2 is : " + d2);
        System.out.println(" Before implementing cosh() so the value of d3 is : " + d3);
        System.out.println(" Before implementing cosh() so the value of d4 is : " + d4);
        System.out.println(" Before implementing cosh() so the value of d5 is : " + d5);

        // By using toRadians() method to convert absolute value into radians.
        d1 = Math.toRadians(d1);
        d2 = Math.toRadians(d2);
        d3 = Math.toRadians(d3);
        d4 = Math.toRadians(d4);
        d5 = Math.toRadians(d5);

        // Here , we will get (infinity) because we are 
        // passing parameter whose value is (infinity)
        System.out.println("After implementing cos() so the value of d1 is : " + Math.cosh(d1));

        // Here , we will get (infinity) because we are 
        // passing parameter whose value is (-infinity)
        System.out.println("After implementing cosh() so the value of d2 is : " + Math.cosh(d2));

        // Here , we will get (1.0) because we are passing parameter
        // whose value is (0.0)
        System.out.println("After implementing cosh() so the value of d3 is : " + Math.cosh(d3));

        // Here , we will get (1.0) because we are passing parameter 
        // whose value is (-0.0)
        System.out.println("After implementing cosh() so the value of d4 is : " + Math.cosh(d4));

        // Here we will find hyperbolic cosine of d5 by using cosh() method
        System.out.println("After implementing cosh() so the value of d5 is : " + Math.cosh(d5));
    }
}

Output

输出量

E:\Programs>javac CoshMethod.java

E:\Programs>java CoshMethod

Before implementing cosh() so the value of d1 is : Infinity
Before implementing cosh() so the value of d2 is : -Infinity
Before implementing cosh() so the value of d3 is : 0.0
Before implementing cosh() so the value of d4 is : -0.0
Before implementing cosh() so the value of d5 is : 60.0
After implementing cos() so the value of d1 is : Infinity
After implementing cosh() so the value of d2 is : Infinity
After implementing cosh() so the value of d3 is : 1.0
After implementing cosh() so the value of d4 is : 1.0
After implementing cosh() so the value of d5 is : 1.600286857702386


翻译自: https://www.includehelp.com/java/math-class-static-double-cosh-double-d-with-example.aspx

log cosh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值