sinh() Function
The sinh() function computes the hyperbolic sine of a given value. It is part of the C math library and provides a way to obtain the hyperbolic sine, which is useful in various mathematical computations involving hyperbolic functions.
Syntax of sinh()
</>
                        Copy
                        double sinh(double x);
float sinhf(float x);
long double sinhl(long double x);Parameters
| Parameter | Description | 
|---|---|
| x | Value representing a hyperbolic angle (in radians). | 
Return Value
The function returns the hyperbolic sine of the given value. In case of an overflow, the appropriate HUGE_VAL constant is returned and an overflow range error is triggered.
Examples for sinh()
Example 1: Computing Hyperbolic Sine for a Positive Angle
This example demonstrates how to compute the hyperbolic sine of a positive value using sinh().
Program
</>
                        Copy
                        #include <stdio.h>
#include <math.h>
int main() {
    double value = 1.0;
    double result = sinh(value);
    printf("sinh(%f) = %f\n", value, result);
    return 0;
}Explanation:
- The variable valueis initialized with a positive angle (in radians).
- The sinh()function computes the hyperbolic sine of this value.
- The result is then printed to the console.
Program Output:
sinh(1.000000) = 1.175201Example 2: Computing Hyperbolic Sine for a Negative Angle
This example demonstrates the computation of the hyperbolic sine for a negative value.
Program
</>
                        Copy
                        #include <stdio.h>
#include <math.h>
int main() {
    double value = -1.0;
    double result = sinh(value);
    printf("sinh(%f) = %f\n", value, result);
    return 0;
}Explanation:
- The variable valueis set to a negative angle.
- The sinh()function calculates the hyperbolic sine for this negative value.
- The result, which is negative, is printed to the console.
Program Output:
sinh(-1.000000) = -1.175201Example 3: Handling Large Values Leading to Overflow
This example shows how the sinh() function behaves when the input is so large that it causes an overflow.
Program
</>
                        Copy
                        #include <stdio.h>
#include <math.h>
#include <errno.h>
int main() {
    errno = 0;
    double value = 1000.0;
    double result = sinh(value);
    if(errno == ERANGE) {
        printf("Overflow occurred, result = %f\n", result);
    } else {
        printf("sinh(%f) = %f\n", value, result);
    }
    return 0;
}Explanation:
- The variable valueis assigned a large number, which may result in an overflow.
- The global variable errnois reset to 0 before callingsinh().
- The sinh()function is called, and the result is checked for an overflow error.
- If an overflow occurs, an appropriate message is printed along with the result.
Program Output:
Overflow occurred, result = inf