📜  C#| Math.Cosh()方法

📅  最后修改于: 2021-05-29 14:25:56             🧑  作者: Mango

Math.Cosh()是内置的Math类方法,该方法返回给定双值参数的双曲余弦值。

句法:

public static double Cosh(double num)

参数:

返回值:该方法返回System.Double类型的num的双曲余弦。如果num等于NegativeInfinity或PositiveInfinity,则返回PositiveInfinity。如果num等于NaN,则返回NaN。

例子:

Input   : 60.0
Output  : 5.71003694907842E+25

下面的程序说明了Math.Cosh方法:

程序1:

// C# program to illustrate the
// Math.Cosh()
using System;
  
class GFG {
    
    // Main Method
    public static void Main(String[] args)
    {
  
        double num1 = 60.0, num2 = 0.0, num3 = 1.0;
  
        // It returns the hyperbolic cosine of 
        // specified angle in radian
        double coshvalue = Math.Cosh(num1);
        Console.WriteLine("The cosh of num1 = " + coshvalue);
  
        coshvalue = Math.Cosh(num2);
        Console.WriteLine("The cosh of num2 = " + coshvalue);
  
        coshvalue = Math.Cosh(num3);
        Console.WriteLine("The cosh of num3 = " + coshvalue);
    }
}
输出:
The cosh of num1 = 5.71003694907842E+25
The cosh of num2 = 1
The cosh of num3 = 1.54308063481524

程式2:

// C# praogram to illustrate the
// Math.Cosh() Method
using System;
  
class GFG {
     
    // Main Method
    public static void Main(String[] args)
    {
  
        double num1 = (30 * (Math.PI)) / 180, num2 = 11.0, num3 = 45.0;
  
        // It returns the hyperbolic cosine of 
        // angle in radian
        double coshvalue = Math.Cosh(num1);
        Console.WriteLine("The cosh of num1 = " + coshvalue);
  
        coshvalue = Math.Cosh(num2);
        Console.WriteLine("The cosh of num2 = " + coshvalue);
  
        coshvalue = Math.Cosh(num3);
        Console.WriteLine("The cosh of num3 = " + coshvalue);
    }
}
输出:
The cosh of num1 = 1.14023832107643
The cosh of num2 = 29937.0708659498
The cosh of num3 = 1.74671355287425E+19