JavaScript Math.cosh() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

Math.cosh(x) returns the hyperbolic cosine of a number. It is defined as (ex + e-x) / 2. The result is always 1 or greater.

Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().

Syntax

Call Math.cosh() like this. Start with this line.

JavaScript
Math.cosh(x)
CallWhat it does
Math.cosh(x)Returns the hyperbolic cosine of x.

Built into JavaScript. Call Math.cosh() on the Math object — no import required.

Library declarations
JavaScript
Math.cosh(x)
JavaScript
interface Math {
  cosh(x: number): number;
}

Parameters

ParameterDescription
xRequired. A number. Other values are converted to a number first.

Return Value

Return ValueDescription
numberThe hyperbolic cosine of x (1 or greater). Returns NaN if x cannot be turned into a number.

JavaScript Examples

Example 1 — Basic Use

The smallest result is 1. The result is the same for x and -x.

JavaScript
console.log(Math.cosh(0));     // 1
console.log(Math.cosh(1));     // 1.5430806348152437
console.log(Math.cosh(-1));    // 1.5430806348152437
console.log(Math.cosh(10));    // 11013.232920103324
Try It Yourself

How It Works

  1. Zero. Math.cosh(0) is 1, the minimum.
  2. Mirror. Math.cosh(1) and Math.cosh(-1) are the same.
  3. Grows fast. Even 10 gives a big number.

Example 2 — Check With the exp() Formula

Compare Math.cosh() with (e^x + e^-x) / 2.

JavaScript
function coshFormula(x) {
  return (Math.exp(x) + Math.exp(-x)) / 2;
}

console.log(Math.cosh(2).toFixed(6));    // 3.762196
console.log(coshFormula(2).toFixed(6));  // 3.762196
Try It Yourself

How It Works

  1. Formula. Math.exp(x) is e to the power x.
  2. Average. Add exp(x) and exp(-x), then divide by 2.
  3. Same answer. Both lines print the same value.

Example 3 — Hanging Cable (Catenary)

A cable that hangs between two poles forms a curve called a catenary: y = a * cosh(x / a).

JavaScript
var a = 2;

for (var x = 0; x <= 4; x += 2) {
  var y = a * Math.cosh(x / a);
  console.log("x = " + x + ", y = " + y.toFixed(3));
}
Try It Yourself

How It Works

  1. Pick a shape. a controls how tight the cable is.
  2. Loop over x. Check the positions 0, 2 and 4.
  3. Height. a * Math.cosh(x / a) is the height. It is lowest at x = 0.

Browser & Runtime Support

Math.cosh() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Math.cosh()

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.cosh Excellent

Bottom line: Use Math.cosh() in new code. Only very old browsers, like Internet Explorer, lack it.

Frequently Asked Questions

Math.cosh(x) returns the hyperbolic cosine of x, which is (e^x + e^-x) / 2. Math.cosh(0) is 1.
The smallest result is 1, at x = 0. For all other inputs the result is bigger.
Yes. Hyperbolic cosine is an even function, so Math.cosh(-2) equals Math.cosh(2).
It is used in science and engineering, for example to describe the curve of a hanging cable (a catenary).
It was added in ES2015 and works in all modern browsers and Node.js.

Next: exp()

Learn how to raise e to a power.

exp() 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.

10 people found this page helpful