![The C Standard Library Reference](/c_standard_library/images/c-mini-logo.jpg)
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <complex.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <fenv.h>
- C Library - <float.h>
- C Library - <inttypes.h>
- C Library - <iso646.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdalign.h>
- C Library - <stdarg.h>
- C Library - <stdbool.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <tgmath.h>
- C Library - <time.h>
- C Library - <wctype.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library - csinh() function
The C complex library csinh() function is used to calculate the hyperbolic sinh of z(complex number). The hyperbolic sine function has properties similar to the regular sine function except it is related to hyperbolas instead of circles.
The hyperbolic sine (sinh) complex number (z) is defined as: sinh(z)= ez - e-z/2
This function is depends on the type of z(complex number). If the z is the "float" type, we use csinhf() to compute sinh, For long double type, use csinhl(), and for double type, use csinh().
Syntax
Following is the C library syntax of csinh() function −
double complex csinh( double complex z );
Parameters
This function accepts a single parameter −
-
Z − It represent a complex number for which we want to calculate sinh.
Return Value
This function returns the complex hyperbolic sine of z (complex number).
Example 1
Following is the basic c program to demonstrate the use of csinh() on a complex number.
#include <stdio.h> #include <complex.h> int main() { double complex z = 3.0 + 4.0 * I; // Calculate the sinh double complex res = csinh(z); printf("Complex sinh: %.2f%+.2fi\n", creal(res), cimag(res)); return 0; }
Output
Following is the output −
Complex sinh: -6.55-7.62i
Example 2
Let's see another example, calculate the hyperbolic sine of real line using csinh() function.
#include <stdio.h> #include <math.h> #include <complex.h> int main(void) { // real line double complex z = csinh(1); printf("sinh(1+0i) = %f+%fi (sinh(1)=%f)\n", creal(z), cimag(z), sinh(1)); }
Output
Following is the output −
Square root of -4 is 0.0+2.0i
Example 3
The below program, calculate the hyperbolic sine of the imaginary line using csinh() function.
#include <stdio.h> #include <math.h> #include <complex.h> int main(void) { // imaginary line double complex z2 = csinh(I); printf("sinh(0+1i) = %f+%fi ( sin(1)=%f)\n", creal(z2), cimag(z2), sin(1)); }
Output
Following is the output −
sinh(0+1i) = 0.000000+0.841471i ( sin(1)=0.841471)