C# Math - Cosh() Method
The C# Cosh() method returns hyperbolic cosine of a value. The hyperbolic cosine of x is defined as:
where e is an Euler's number.
In special cases it returns the following:
- If the argument is NaN, the method returns NaN.
- If the argument is positive infinity or negative infinity, the method returns positive infinity.
Syntax
public static double Cosh(double arg);
Parameters
arg |
Specify the value. |
Return Value
Returns the hyperbolic cosine of a value.
Example:
In the example below, Cosh() method is used to find out the hyperbolic cosine of a value.
using System; class MyProgram { static void Main(string[] args) { Console.WriteLine("Math.Cosh(-2) = " + Math.Cosh(-2)); Console.WriteLine("Math.Cosh(-1) = " + Math.Cosh(-1)); Console.WriteLine("Math.Cosh(0) = " + Math.Cosh(0)); Console.WriteLine("Math.Cosh(1) = " + Math.Cosh(1)); Console.WriteLine("Math.Cosh(2) = " + Math.Cosh(2)); Console.WriteLine("Math.Cosh(Double.NaN) = " + Math.Cosh(Double.NaN)); Console.WriteLine("Math.Cosh(Double.NegativeInfinity) = " + Math.Cosh(Double.NegativeInfinity)); Console.WriteLine("Math.Cosh(Double.PositiveInfinity) = " + Math.Cosh(Double.PositiveInfinity)); } }
The output of the above code will be:
Math.Cosh(-2) = 3.76219569108363 Math.Cosh(-1) = 1.54308063481524 Math.Cosh(0) = 1 Math.Cosh(1) = 1.54308063481524 Math.Cosh(2) = 3.76219569108363 Math.Cosh(Double.NaN) = NaN Math.Cosh(Double.NegativeInfinity) = Infinity Math.Cosh(Double.PositiveInfinity) = Infinity
❮ C# Math Methods