
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Program to Find Hyperbolic Sine of Given Radian Value
Normal trigonometric functions have analogous to hyperbolic functions, which are defined using the hyperbola rather than the circle. In hyperbolic geometry, hyperbolic functions are used to calculate angles and distances. Additionally, they appear in the answers to a lot of linear differential equations, cubic equations, etc. For given angle$\theta$. The hyperbolic sine function sinh$(\theta)$ is like 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 shall discuss the techniques to get the value of sinh$(\theta)$ in C++ when the angle is given in the radian unit.
The sinh() function
To compute the sinh$(\theta)$ The sinh() function from the cmath package will be used. This function returns the result of hyperbolic sine by taking the angle in radians as input. Here, the simple syntax is used:
Syntax
#include < cmath > sinh( <angle in radian> )
Algorithm
- Take angle x in radian as input.
- Use sinh( x ) to calculate the sinh (x).
- Return result.
Example
#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; }
Output
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, whereas the latter two input values are in degrees that have been converted to radians using the formula below ?
$$\mathrm{\theta_{rad}\:=\:\theta_{deg}\:\times\:\frac{\pi}{180}}$$
Conclusion
To find the hyperbolic sine value in radians for the given angle in C++, use the sinh() function. Even though this function is a part of the standard library, our C++ code needs to include the cmath header file to use it. The sinh() function returns the value HUGE_VAL (positive or negative depending on the value of x) if the result is too large 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 for integral types, but the C90 version of C++ had a double return type. The article has used a variety of arguments with this function, either in radians or degrees; however, for degrees, the values are converted into radians using the formula given above.