C++ cosh()
Anonymous contributor
Published Jul 20, 2021Updated Apr 28, 2023
The cosh() function returns the hyperbolic cosine of an argument given in radians.
Syntax
std::cosh(angle)
The angle is measured in radians and the return type is a double, float, or long double.
If the magnitude of the result is too large to express, the function returns HUGE_VAL (positive or negative) and an overflow range error is thrown.
The mathematical formula used in cosh() looks like this:
Example
This example uses cosh() to return the hyperbolic cosine of 0.0 radians:
#include <iostream>#include <cmath>int main() {double x = 0.0;double result;result = std::cosh(x);std::cout << "The hyperbolic cosine of " << x << " radians is " << result << "\n";// Output: The hyperbolic cosine of 0 radians is 1}
Codebyte Example
This example uses cosh() to return the hyperbolic cosine of 1.0 radians:
All contributors
- Anonymous contributor
- StevenSwiniarski
- Anonymous contributor
Christine_Yang- garanews
- Anonymous contributor
christian.dinh
Learn C++ on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.
- Beginner Friendly.11 hours