# MathF.Cosh() Method in C# with Examples

Math.Cosh(Single) Method is the inbuilt MathF class method which returns the hyperbolic cosine of a given single value argument.

Syntax: public static float Cosh (float x);
Here, x is the number whose hyperbolic cosine is to be returned and type of this parameter is System.Single.

Return Value: This method returns the hyperbolic cosine of x of type System.Single. If x is equal to NegativeInfinity or PositiveInfinity, PositiveInfinity is returned. If x is equal to NaN, NaN is returned.

Below programs illustrate the use of the above-discussed method:

Example 1:

 `// C# program to illustrate the ` `// MathF.Cosh(Single) Method ` `using` `System; ` ` `  `class` `GFG { ` ` `  `    ``// Main Method ` `    ``public` `static` `void` `Main(String[] args) ` `    ``{ ` ` `  `        ``float` `num1 = 60.0f, num2 = 0.0f, num3 = 1.0f; ` ` `  `        ``// It returns the hyperbolic cosine  ` `        ``// of specified angle in radian ` `        ``float` `coshvalue = MathF.Cosh(num1); ` `        ``Console.WriteLine(``"The Cosh of num1 = "` `+ coshvalue); ` ` `  `        ``coshvalue = MathF.Cosh(num2); ` `        ``Console.WriteLine(``"The Cosh of num2 = "` `+ coshvalue); ` ` `  `        ``coshvalue = MathF.Cosh(num3); ` `        ``Console.WriteLine(``"The Cosh of num3 = "` `+ coshvalue); ` `    ``} ` `} `

Output:

```The Cosh of num1 = 5.710037E+25
The Cosh of num2 = 1
The Cosh of num3 = 1.543081
```

Example 2:

 `// C# praogram to illustrate the ` `// MathF.Cosh(Single) Method ` `using` `System; ` ` `  `class` `GFG { ` ` `  `    ``// Main Method ` `    ``public` `static` `void` `Main() ` `    ``{ ` `         `  `        ``float` `num1 = (30 * (MathF.PI)) / 180; ` `         `  `        ``// calling result() method ` `        ``result(num1); ` `        ``result(Single.NaN); ` `        ``result(Single.NegativeInfinity); ` `        ``result(Single.PositiveInfinity); ` `    ``} ` ` `  `    ``// defining result() method ` `    ``public` `static` `void` `result(``float` `value) ` `    ``{ ` ` `  `        ``// using the method ` `        ``float` `result = MathF.Cosh(value); ` ` `  `        ``// Display the value ` `        ``Console.WriteLine(``"Cosh({0}) will be {1}"``, ` `                                ``value, result); ` `    ``} ` `} `

Output:

```Cosh(0.5235988) will be 1.140238
Cosh(NaN) will be NaN
Cosh(-Infinity) will be Infinity
Cosh(Infinity) will be Infinity
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.