cosh()
Anonymous contributor
Published Jul 20, 2021Updated Apr 28, 2023
Contribute to Docs
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
- Christine_Yang
- garanews
- Anonymous contributor
- christian.dinh
- Anonymous contributor
- StevenSwiniarski
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C++
Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.Beginner Friendly11 hours