C# Math.Cosh() – Examples

In this tutorial, we will learn about the C# Math.Cosh() method, and learn how to use this method to find the hyperbolic cosine of given angle, with the help of examples.

Cosh(Double)

Math.Cosh(value) returns the hyperbolic cosine of the specified angle value.

ADVERTISEMENT

Syntax

The syntax of Cosh() method is

Math.Cosh(Double value)

where

ParameterDescription
valueThe value represents radians for which hyperbolic cosine is to be calculated.

Return Value

The method returns value of type Double.

Example 1 – Cosh(Double)

In this example, we will find the hyperbolic cosine of some angles like 1 radian, PI radians, PI/2 radians, 0 radians, Infinity radians, -Infinity radians.

C# Program

using System;
 
class Example {
    static void Main(string[] args) {
        Double value, result;

        value = 1; //1 radian
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");

        value = Math.PI; // PI radians or 180 degrees
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");

        value = Math.PI/2; // 90 degrees
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");

        value = 0; // 0 degrees
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");

        value = Double.PositiveInfinity;
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");

        value = Double.NegativeInfinity;
        result = Math.Cosh(value);
        Console.WriteLine($"Cosh({value} radian) = {result}.");
    }
}

Output

Cosh(1 radian) = 1.54308063481524.
Cosh(3.14159265358979 radian) = 11.5919532755215.
Cosh(1.5707963267949 radian) = 2.50917847865806.
Cosh(0 radian) = 1.
Cosh(∞ radian) = ∞.
Cosh(-∞ radian) = ∞.

Conclusion

In this C# Tutorial, we have learnt the syntax of C# Math.Cosh() method, and also learnt how to use this method with the help of C# example programs.