Hyperbolic Functions in C Standard Library

Question: What are Different Hyperbolic Functions in Standard C Library?

Answer: We have following hyperbolic functions defined and prototyped in ‘math.h’ header.

   double sinh(double angle);
   double cosh(double angle);
   double tanh(double angle);

These functions return the hyperbolic sine, hyperbolic cosine and hyperbolic tangent of their arguments respectively. Each function takes angle, in radians, as its argument. Let’s learn to use ‘sinh()’ in a C program below,

/* fp_sinhyperbolic_fun.c -- 'sinh()' returns hyperbolic sine of */
/* angle in radians */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void)
{
    double angle, result;
 
    printf("User, write in angle ,in radians, whose hyperbolic sine "
            "to be computed...\n");
    scanf("%lf", &angle);
 
    /* calling 'sinh()' to compute hyperbolic sine of angle */
    result = sinh(angle);
 
    printf("hyperbolic sine of \"angle: %lf\" is:%lf\n",
            angle, result);
 
    return 0;
}

The sinh() function returns the hyperbolic sine of angle, say x, which is defined mathematically as:

advertisement
advertisement
           sinh(x) = (exp(x) - exp(-x)) / 2

Output of the above program follows:

User, write in angle ,in radians, whose hyperbolic sine to be computed...
+0.0
hyperbolic sine of "angle: 0.000000" is:0.000000
 
User, write in angle ,in radians, whose hyperbolic sine to be computed...
-0.0
hyperbolic sine of "angle: -0.000000" is:-0.000000
 
User, write in angle ,in radians, whose hyperbolic sine to be computed...
10
hyperbolic sine of "angle: 10.000000" is:11013.232875
 
User, write in angle ,in radians, whose hyperbolic sine to be computed...
1000000000000000
hyperbolic sine of "angle: 1000000000000000.000000" is:inf

Observe the last case where output turned out as ‘inf’, short for infinity, for very large angle. Try using other functions to see their outputs.

Sanfoundry Global Education & Learning Series – 1000 C Tutorials.

If you wish to look at all C Tutorials, go to C Tutorials.

advertisement

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.