Hyperbolic functions are analogs of trigonometric functions, but they relate to hyperbolas rather than circles. These functions are widely used in areas such as engineering, physics, and mathematics, particularly in solving certain types of differential equations and in the study of hyperbolic geometry. In C++, the <cmath>
module provides a comprehensive set of hyperbolic functions. This article explores these functions, their usage, and practical applications.
Hyperbolic functions are based on the hyperbola, much like trigonometric functions are based on the circle. The primary hyperbolic functions are hyperbolic sine (sinh
), hyperbolic cosine (cosh
), and hyperbolic tangent (tanh
). There are also their inverse functions: asinh
, acosh
, and atanh
.
<cmath>
The <cmath>
module includes several functions for working with hyperbolic values. Each of these functions takes a double value as input and returns a double value as output.
The sinh(double x)
function computes the hyperbolic sine of x
.
#include <iostream>
#include <cmath>
int main() {
double value = 1.0;
std::cout << "sinh(" << value << ") = " << sinh(value) << std::endl; // Output: 1.1752
return 0;
}
The cosh(double x)
function computes the hyperbolic cosine of x
.
#include <iostream>
#include <cmath>
int main() {
double value = 1.0;
std::cout << "cosh(" << value << ") = " << cosh(value) << std::endl; // Output: 1.54308
return 0;
}
The tanh(double x)
function computes the hyperbolic tangent of x
.
#include <iostream>
#include <cmath>
int main() {
double value = 1.0;
std::cout << "tanh(" << value << ") = " << tanh(value) << std::endl; // Output: 0.761594
return 0;
}
The inverse hyperbolic functions compute the value whose hyperbolic function is the given number. These functions are useful for solving equations involving hyperbolic functions.
The asinh(double x)
function computes the inverse hyperbolic sine of x
.
#include <iostream>
#include <cmath>
int main() {
double value = 1.0;
std::cout << "asinh(" << value << ") = " << asinh(value) << std::endl; // Output: 0.881374
return 0;
}
The acosh(double x)
function computes the inverse hyperbolic cosine of x
. Note that the domain of acosh
is [1, ∞).
#include <iostream>
#include <cmath>
int main() {
double value = 1.5;
std::cout << "acosh(" << value << ") = " << acosh(value) << std::endl; // Output: 0.962424
return 0;
}
The atanh(double x)
function computes the inverse hyperbolic tangent of x
. Note that the domain of atanh
is (-1, 1).
#include <iostream>
#include <cmath>
int main() {
double value = 0.5;
std::cout << "atanh(" << value << ") = " << atanh(value) << std::endl; // Output: 0.549306
return 0;
}
Hyperbolic functions are used in various practical applications, especially in the fields of engineering, physics, and mathematics.
In structural engineering, hyperbolic functions are used to describe the shape of hanging cables or chains, known as catenaries. This shape is defined by the hyperbolic cosine function.
In physics, hyperbolic functions appear in the study of special relativity. The rapidity parameter, which is used to describe the relative velocity between two inertial frames, is expressed in terms of hyperbolic functions.
In electrical engineering, hyperbolic functions are used to solve transmission line equations. They help describe the voltage and current along a transmission line.
Consider an example where we need to calculate the length of a cable hanging between two poles of the same height, forming a catenary curve. The shape of the cable can be described by the hyperbolic cosine function.
#include <iostream>
#include <cmath>
int main() {
double a = 1.0; // Constant parameter of the catenary
double x = 2.0; // Horizontal distance from the lowest point of the cable
double y = a * cosh(x / a);
std::cout << "The height of the cable at distance " << x << " from the lowest point is " << y << std::endl; // Output: 3.7622
return 0;
}