C++ Hyperbolic Trigonometric functions














































C++ Hyperbolic Trigonometric functions



 The C++ <cmath> header file declares a set of functions to perform mathematical   operations such as the elementary exponential, logarithm, square root, and trigonometric   functions etc.
 Note:- All the functions take input in radians and not degrees
 1. sinh( )The sinh() function in C++ takes angle (in radians) as an argument and
returns the hyperbolic sine of an angle given in in double, float or long
double type.
sinh x = (e^(x) - e^(-x)) / 2
         Syntax :- float sinh(float x);
                         double sinh(double x);
                         long double sinh(long double x);
                         double sinh(T x);  ( for integral type )

         Parameter :- The sinh() function takes a single mandatory argument in radians.

         Return value :- The sinh() function returns the hyperbolic sine of the argument. If
the magnitude of the result is too large to be represented by a
value of the return type, the function returns HUGE_VAL with the
proper sign, and an overflow range error occurs.


 2. cosh( )The cosh() function in C++ takes angle (in radians) as an argument and
returns the hyperbolic cosine of an angle given in in double, float or long
double type.
cosh x = (e^(x) + e^(-x)) / 2
         Syntax :- double cosh(double x);
                         float cosh(float x);
                         long double cosh(long double x);
                         double cosh(T x); ( Here, T is an integral type )

         Parameter :- The cosh() function takes a single mandatory argument in radians.

         Return value :- The cosh() function returns the hyperbolic cosine of the argument. If
the magnitude of the result is too large to be represented by a
value of the return type, the function returns HUGE_VAL with the
proper sign, and an overflow range error occurs.


 3. tanh( )The tanh() function in C++ takes angle (in radians) as an argument and
returns the hyperbolic tangent of an angle given in in double, float or long
double type.
tanh x = (e^(x) - e^(-x)) / (e^(x) + e^(-x))
         Syntax :- float tanh(float x);
                         double tanh(double x);
                         long double tanh(long double x);
                         double tanh(T x);  ( for integral type )

         Parameter :- The tanh() function takes a single mandatory argument in radians.

         Return value :- The tanh() function returns the hyperbolic tangent of the argument.


Code of Trigonometric functions all together :

#include <iostream> #include <cmath> using namespace std; int main() { double x, y; cout << "Enter the value of number x (in radians): "; cin >> x; cout << "\nhyperbolic sine value of x = " << x << " is => " << sinh(x); cout << "\nhyperbolic cosine value of x = " << x << " is => " << cosh(x); cout << "\nhyperbolic tangent value of x = " << x << " is => " << tanh(x); cout << "\n\nEnter the value of number y (in degree): "; cin>> y; // converting degree into radians double rad = y * 3.14159 / 180; cout << "\nhyperbolic sine value of y = " << y << " degree is => " << sinh(rad); cout << "\nhyperbolic cosine value of y = " << y << " degree is => " << cosh(rad); cout << "\nhyperbolic tangent value of y = " << y << " degree is => " << tanh(rad); return 0; }

Output:-
Enter the value of number x (in radians): 2.7 hyperbolic sine value of x = 2.7 is => 7.40626 hyperbolic cosine value of x = 2.7 is => 7.47347 hyperbolic tangent value of x = 2.7 is => 0.991007 Enter the value of number y (in degree): 45 hyperbolic sine value of y = 45 degree is => 0.86867 hyperbolic cosine value of y = 45 degree is => 1.32461 hyperbolic tangent value of y = 45 degree is => 0.655794



Comments