Ordinary trigonometric functions are similar to hyperbolic functions in that they are defined using hyperbolas instead of circles. In hyperbolic geometry, hyperbolic functions are used to calculate angles and distances. Additionally, they appear in the answers to many linear differential equations, cubic equations, etc. For a given angle $\theta$. The hyperbolic sine function sinh$(\theta)$ is shown below.
$$\mathrm{sinh(x)\:=\:\frac{e^x\:-\:e^{-x}}{2}\:=\:\frac{e^{2x }-1}{2e^x}\:=\:\frac{1-e^{-2x}}{2e^{-x}}}$$
In this article we will discuss techniques for obtaining the value of sinh$(\theta)$ in C when the angle is given in radians.
To calculate sinh$(\theta)$, the sinh() function in the cmath package will be used. This function takes as input an angle in radians and returns the result of a hyperbolic sine. Here, use simple syntax:
#include < cmath > sinh( <angle in radian> )
#include <iostream> #include <cmath> using namespace std; float solve( float x ) { float answer; answer = sinh( x ); return answer; } int main() { cout << "The value of sinh( pi/2 ) is: " << solve( 3.14159 / 2 ) << endl; cout << "The value of sinh( pi ) is: " << solve( 3.14159 ) << endl; cout << "The value of sinh with an angle of 90 degrees is: " << solve( 90 * 3.14159 / 180 ) << endl; cout <<"The value of sinh with an angle of 45 degrees is: " << solve( 45 * 3.14159 / 180 ) << endl; }
The value of sinh( pi/2 ) is: 2.3013 The value of sinh( pi ) is: 11.5487 The value of sinh with an angle of 90 degrees is: 2.3013 The value of sinh with an angle of 45 degrees is: 0.86867
The first two input values in this example are in radians, while the last two input values are in degrees and have been converted to radians using the following formula -
$$\mathrm{\theta_{rad}\:=\:\theta_{deg}\:\times\:\frac{\pi}{180}}$$
To find the hyperbolic sine of a given angle in radians in C, use the sinh() function. Although this function is part of the standard library, our C code needs to include the cmath header file to use it. If the result is too large, the sinh() function returns the value HUGE_VAL (positive or negative, depending on the value of x) and sets the error number to ERANGE. Later versions of C provided overloaded methods for float and long double, as well as enhanced generic (template) usage of integer types, but the C90 version of C has a double return type. This article uses the various parameters of the function, in radians or degrees; however, for degrees, the value is converted to radians using the formula given above.
The above is the detailed content of C++ program to calculate the hyperbolic sine of a given value in radians. For more information, please follow other related articles on the PHP Chinese website!