The cosh() function computes the hyperbolic cosine of a real number. Built from exponentials—(ex + e−x) / 2—it always returns a value ≥ 1 and appears in physics, engineering, and special relativity formulas.
01
Hyperbolic
Not circular.
02
math.h
Link with -lm.
03
Any real x
Full domain.
04
Output ≥ 1
Min at 0.
05
Even fn
cosh(−x).
06
vs cos
Different.
Fundamentals
Definition and Usage
Hyperbolic cosine is defined as cosh(x) = (ex + e−x) / 2, where e is Euler’s number (about 2.718). Unlike circular cos(), which oscillates between −1 and 1, cosh(x) grows smoothly and is always at least 1.
The input x is any real number—not a degree or radian angle in the circular sense. Think of it as a hyperbolic parameter. At x = 0, both exponentials contribute equally and cosh(0) = 1.
💡
Beginner Tip
Do not confuse cosh() with cos(). cos needs radians and returns values in [−1, 1]. cosh takes any real number and always returns ≥ 1. The inverse of cosh on outputs ≥ 1 is acosh().
The manual formula matches the library. In production code, prefer cosh()—it handles overflow and precision better than naive exp combinations for extreme values.
Example 5 — cosh() vs cos() at the Same Input
See why these are different functions despite similar names.
C
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
int main(void) {
double vals[] = { 0.0, 1.0, 1.5, M_PI / 3 };
size_t i;
printf(" x cosh(x) cos(x)\n");
for (i = 0; i < 4; i++) {
double x = vals[i];
printf("%5.2f %8.4f %8.4f\n", x, cosh(x), cos(x));
}
return 0;
}
They only agree at x = 0 (both return 1). For other inputs, cosh grows while cos oscillates in [−1, 1]. Note: 1.05 is π/3 radians (60°) for the last row—cos needs radians; cosh does not.
Applications
🚀 Common Use Cases
Catenary curves — shape of a hanging cable: y = a · cosh(x/a).
Special relativity — Lorentz factor involves cosh in rapidity formulations.
Signal processing — hyperbolic functions in filter design.
Heat and diffusion — solutions to differential equations.
Pair with sinh() — hyperbolic identities like cosh²(x) − sinh²(x) = 1.
🧠 How cosh() Works
1
Receive real x
Any finite real number (positive, negative, or zero).
Input
2
Compute exponentials
Evaluate ex and e−x, average them.
Compute
3
Return ≥ 1
Result is a double always at least 1.0.
Output
=
🔢
Hyperbolic cosine
Use acosh(y) to reverse when y ≥ 1.
Important
📝 Notes
Defined as (ex + e−x) / 2.
Domain: all real numbers (not just 0 to ∞).
Range: ≥ 1; minimum at cosh(0) = 1.
Even function: cosh(-x) == cosh(x).
Not the same as cos()—no degree/radian conversion needed.
Very large |x| may cause overflow; the library handles this gracefully.
Performance
⚡ Optimization
cosh() is implemented in the platform math library with careful handling of overflow. Avoid rewriting it as (exp(x) + exp(-x)) / 2 in hot loops—direct exp calls can overflow sooner. Use coshf when float precision is sufficient to save memory bandwidth.
Wrap Up
Conclusion
cosh() computes hyperbolic cosine from exponentials, accepts any real input, and always returns a value ≥ 1. It is distinct from circular cos() and pairs with acosh() as its inverse on outputs ≥ 1.
Continue with exp() to explore exponentials further, or review acosh() for the inverse operation.
cosh() returns the hyperbolic cosine of x, computed as (e^x + e^(-x)) / 2. For example, cosh(0) is 1.0 and cosh(1.5) is about 2.352. It is not the same as the circular cosine function cos().
Include <math.h> and link with -lm on many systems: gcc program.c -o program -lm. The function is declared as double cosh(double x).
Neither in the usual trig sense. cosh(x) takes any real number x as a hyperbolic argument. You do not convert degrees to radians before calling cosh() the way you do for cos().
The result is always greater than or equal to 1. cosh(0) is exactly 1 (the minimum). As |x| grows, cosh(x) grows rapidly toward infinity.
cos() is circular trigonometry (input in radians, output in [-1, 1]). cosh() is hyperbolic (input is any real, output >= 1). They share a similar name but solve different math problems.
Yes. The domain is all real numbers. cosh() is an even function: cosh(-x) equals cosh(x). The old claim that input must be from 0 to infinity is incorrect.
Did you know?
A hanging chain or cable forms a catenary curve described by y = a · cosh(x/a). Architects have used this shape for centuries—the Gateway Arch in St. Louis is a famous scaled catenary, not a parabola.