# How to manage hyperbolic functions in Python

First, let us see the basic definition of the function. “A function is a block of organized code that performs some specific task.”

In this tutorial, we are going to study about the hyperbolic functions of math module on complex numbers in Python.

Many built-in functions are defined in the math module, and they can be used for any of Python calculations like hyperbolic calculations.

First of all, let us perform the basic trigonometric functions sin, cos, tan functions. These functions will return the sin, cosine, tangent of a given number as an argument. Consider the example.

```import math
x=1.25
print("sin value is:",math.sin(x))
print("cos value is:",math.cos(x))
print("tan value is:",math.tan(x))
```

Output :

```sin value is: 0.9489846193555862
cos value is: 0.3153223623952687
tan value is: 3.0095696738628313```

Example On complex numbers

```import cmath
x=1.5
y=1.5
#converting x and y to complex number z
z=complex(x,y)
print("Sin value of complex number is:",end="")
print(cmath.sin(z))
print("cos value of complex number is:",end="")
print(cmath.cos(z))
print("tan value of complex number is:",end="")
print(cmath.tan(z)
```

Here in the above code, we have utilized the cmath library. The cmath helps us to handle the mathematical functions for complex numbers in Python. And this module accepts the integers, floating-point numbers or complex numbers as arguments.

This complex number is represented by x+iy where x and y are the real numbers. We can convert these two real numbers into complex numbers by utilizing the complex function as shown in the above code.

Output :

```The sine value of complex number is:(2.3465167976443118+0.15061927022193866j)
The cos value of complex number is:(0.16640287335850498-2.1239455815360935j)
The tan value of complex number is:(0.01554584115148238+1.1035734368075185j)```

Now the output is in the form of complex number x+iy. Here both x and y are real numbers.

## Performing the hyperbolic functions in Python

Hyperbolic functions: These are similar to trigonometric functions while the trigonometric functions are related to the unit circle and hyperbolic functions are related to a hyperbola. The different hyperbolic functions are:

• sinh returns the hyperbolic sin of a given value.
Syntax: math.sinh(x)
• cosh returns the hyperbolic cos of a given value.
Syntax: math.cosh(x)
• tanh returns the hyperbolic tan of a given value.
Syntax: math.tanh(x)

Here x is the input value. It should be either integer or float type value of hyperbolic functions.

```import cmath
x=1.5
y=1.5
#converting x and y to complex number z
z=complex(x,y)
print("The hyperbolic sine of complex number is:",end="")
print(cmath.sinh(z))
print("The hyperbolic cos of complex number is:",end="")
print(cmath.cosh(z))
print("The hyperbolic tan of complex number is:",end="")
print(cmath.tanh(z))```

Output:

```The hyperbolic sine of complex number is:(0.15061927022193866+2.3465167976443118j)
The hyperbolic cos of complex number is:(0.16640287335850498+2.1239455815360935j)
The hyperbolic tan of complex number is:(1.1035734368075185+0.01554584115148238j)```

If we pass the string type argument to the hyperbolic functions then it may generate the error. Let us see the example.

```import cmath
x="1.25"
print(cmath.sinh(x))
print(cmath.cosh(x))
print(Cmath.tanh(x))```

Output:

```TypeError: must be real number, not str
```

Next, we also have the inverse hyperbolic functions in Python. Consider the example code.

```import cmath
x=1.5
y=1.5
z=complex(x,y)
print("The inverse hyperbolic sine of complex number is",end="")
print(cmath.asinh(z))
print("The inverse hyperbolic cos of complex number is",end="")
print(cmath.acosh(z))
print("The inverse hyperbolic tan of complex number is",end="")
print(cmath.atanh(z))```

Output:

```The inverse hyperbolic sine of complex number is:(1.44973434958536+0.7304012179532257j)
The inverse hyperbolic cos of complex number is:(1.44973434958536+0.8403951088416709j)
The inverse hyperbolic tan of complex number is:(0.3059438579055289+1.2164831907310616j)```