C# Math Cosh() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

In C#, Math.Cosh(value) returns the hyperbolic cosine of a number: (ex + e-x) / 2. Math.Cosh(0) is 1, and the answer is never smaller than 1.

The graph of Cosh is a smooth "U" shape. It is the exact shape of a chain or cable hanging between two poles, called a catenary. Unlike Cos(), it does not wave up and down between -1 and 1. It is the same on both sides of zero, Cosh(-x) = Cosh(x), and it climbs very fast. Its companions are Sinh() and Tanh().

This is a static member of the static class System.Math. You call it with the class name, such as Math.Cosh(...). There is no Math object to create. All the work is done by the method you call, and it never changes your variables. Cosh is in every .NET version. It takes and returns double.

Syntax

Pass any number. The answer is a double of 1 or more.

C#
double a = Math.Cosh(0);     // 1
double b = Math.Cosh(1);     // 1.5430806348152437
double c = Math.Cosh(-1);    // 1.5430806348152437 (same as Cosh(1))
CallWhat it does
Math.Cosh(0)Returns 1, the lowest point of the "U".
Math.Cosh(1)Returns about 1.5431.
Math.Cosh(-1)Returns the same 1.5431. The curve is symmetric.
Math.Cosh(1000)Returns Infinity. The answer is too large for a double.

Cosh is an even function: Cosh(-x) equals Cosh(x). The answer is never below 1 (for a real number). It overflows to Infinity for inputs with a size above about 710. Round non-whole results before showing them. The method never throws.

Library declarations
C#
public static double Cosh(double value);

Parameters

ParameterDescription
valueRequired. Any double. It is a plain number, not an angle.

Return Value

Return ValueDescription
doubleThe hyperbolic cosine of value, which is 1 or more. Infinity for very large inputs (positive or negative), NaN for NaN.

C# Examples

Example 1 — Hyperbolic Cosine of a Few Numbers

Print Cosh for 0, 1, -1, and 2, rounded to 4 decimals.

C#
using System;
using System.Globalization;

class Program {
    static string R(double value) {
        return Math.Round(value, 4).ToString(CultureInfo.InvariantCulture);
    }

    static void Main() {
        Console.WriteLine(R(Math.Cosh(0)));
        Console.WriteLine(R(Math.Cosh(1)));
        Console.WriteLine(R(Math.Cosh(-1)));
        Console.WriteLine(R(Math.Cosh(2)));
    }
}

How It Works

  1. Zero. e to the 0 is 1, so (1 + 1) / 2 is 1. This is the lowest value the function can reach.
  2. One. Cosh(1) is (2.7183 + 0.3679) / 2, about 1.5431.
  3. Minus one. The answer is the same, 1.5431. The left and right sides of the "U" are mirror images.
  4. Two. It climbs quickly: Cosh(2) is about 3.7622.

Example 2 — Cosh Squared Minus Sinh Squared

Check the identity Cosh(x)^2 - Sinh(x)^2 = 1 for three numbers.

C#
using System;

class Program {
    static void Main() {
        foreach (double x in new double[] { 0.5, 1.5, 2 }) {
            double c = Math.Cosh(x);
            double s = Math.Sinh(x);
            Console.WriteLine(Math.Round(c * c - s * s, 6));
        }
    }
}

How It Works

  1. The rule. For every number, the hyperbolic cosine squared minus the hyperbolic sine squared is exactly 1. It is the cousin of "sin squared plus cos squared is 1".
  2. Three inputs. The loop tries 0.5, 1.5, and 2. The two squares are different numbers each time, but their difference is always 1.
  3. Rounding. The two squares are big numbers, and a double keeps only about 15 digits. Rounding to 6 places hides the last-digit noise.
  4. Output. Each line shows 1. If a program ever prints anything else here, the inputs are likely too large for exact subtraction.

Example 3 — The Shape of a Hanging Cable

Use y = a * Cosh(x / a) to find the height of a cable at different positions, and see overflow.

C#
using System;
using System.Globalization;

class Program {
    static string R(double value) {
        return Math.Round(value, 4).ToString(CultureInfo.InvariantCulture);
    }

    static void Main() {
        double a = 2;

        Console.WriteLine(R(a * Math.Cosh(0 / a)));
        Console.WriteLine(R(a * Math.Cosh(2 / a)));
        Console.WriteLine(R(a * Math.Cosh(-2 / a)));
        Console.WriteLine(Math.Cosh(1000));
    }
}

How It Works

  1. The formula. A cable hangs in the curve y = a * Cosh(x / a), where a controls how steep it is. The middle (x = 0) is the lowest point.
  2. The middle. At x = 0 the cosh is 1, so the height is 2, equal to a.
  3. Two steps along. At x = 2 the height rises to about 3.0862. At x = -2 it is the same, because the cable is symmetric.
  4. Too far. Math.Cosh(1000) is too large for a double, so it returns Infinity and does not throw.

Frequently Asked Questions

It returns the hyperbolic cosine of a number, defined as (e^x + e^-x) / 2. Math.Cosh(0) is 1, and the result is never below 1.
Cos works with angles in radians and waves between -1 and 1. Cosh works with a plain number, is never below 1, and grows without limit.
The catenary, which is the curve of a chain or cable hanging under its own weight. The height is a * Cosh(x / a).
Yes. Math.Cosh(-x) equals Math.Cosh(x), so its graph is symmetric around zero.
No. Math is a static class, so you call Math.Cosh(...) straight on the class name. You cannot write new Math(), and there is no variable to keep.

Next: DivRem()

Get the quotient and the remainder of a whole-number division in one call.

DivRem() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful