.Cosh()
The Math.Cosh()
class method returns the hyperbolic cosine of a given angle.
Syntax
Math.Cosh(angle);
The Math.Cosh()
method takes only one parameter, angle
, an angle in radians of type double
. The method returns the hyperbolic cosine of the angle
as a double
value, except if the value of angle
equals:
NaN
(not a number), then it returnsNaN
.NegativeInfinity
, then it returnsPositiveInfinity
.PositiveInfinity
, then it also returnsPositiveInfinity
.
Note: Depending on the operating system or architecture, the exact result or the input range of the
Math.Cosh()
method may differ due to the differences in the C runtime environment.
Example
The following example first converts 45
degrees to radians, then uses the Math.Cosh()
method to return the hyperbolic cosine of that angle. Math.Round()
rounds up the result to five decimals. Finally, the result is printed using Console.WriteLine()
:
using System;public class Example {public static void Main(string[] args) {double degrees = 45;double radians = degrees * Math.PI/180;double hyperbolicCosine = Math.Round(Math.Cosh(radians), 5);Console.WriteLine("The hyperbolic cosine of " + degrees + " degrees is: " + hyperbolicCosine);}}
The example will result in the following output:
The hyperbolic cosine of 45 degrees is: 1.32461
Codebyte Example
The following example is runnable and returns the hyperbolic cosine of the angle
given in degrees:
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.