# Hyperbolic functions in Python

Python Hyperbolic functions: Here, we are going to learn about the hyperbolic functions of math module with examples in Python?
Submitted by IncludeHelp, on April 25, 2019

## Python Hyperbolic functions/methods

In python programming language, there are some of the built-in functions which are defined in math module – they can be used for hyperbolic calculations (these functions are analogs of trigonometric functions those are based on hyperbolas instead of circles.), python has following Hyperbolic functions, which are used to various purposes.

### List of hyperbolic functions in Python

Hyperbolic functions Description Example
math.acosh() It returns hyperbolic arc cosine of the given number. math.acosh(x)
math.asinh() It returns hyperbolic arc sine of the given number. math.asinh(x)
math.atanh() It returns hyperbolic arc tangent of the given number. math.atanh(x)
math.cosh() It returns hyperbolic cosine of the given number. math.cosh(x)
math.sinh() It returns hyperbolic sine of the given number. math.sinh(x)
math.tanh() It returns hyperbolic tangent of the given number. math.tanh(x)

### Python code to demonstrate example of all hyperbolic functions

```# Python code to demonstrate example of
# all hyperbolic functions

# importing math module
import math

# number
x = 1.25

# math.acosh()
print("math.acosh(",x,"): ", math.acosh(x))

# math.asinh()
print("math.asinh(",x,"): ", math.asinh(x))

# math.atanh()
x = 0.56
print("math.atanh(",x,"): ", math.atanh(x))

# math.cosh()
print("math.cosh (",x,"): ", math.cosh(x))

x = 1.25

# math.sinh()
print("math.sinh (",x,"): ", math.sinh(x))

# math.tanh()
print("math.tanh (",x,"): ", math.tanh(x))
```

Output

```math.acosh( 1.25 ):  0.6931471805599453
math.asinh( 1.25 ):  1.0475930126492587
math.atanh( 0.56 ):  0.632833186665638
math.cosh ( 0.56 ):  1.160940782072458
math.sinh ( 1.25 ):  1.6019190803008256
math.tanh ( 1.25 ):  0.8482836399575129
```

### Exceptions with hyperbolic functions

There are two types of exceptions occur,

• ValueError
When we provide an invalid value (number), this exception occurs.
• TypeError
When we provide a different type of values except a number, this exception occurs.

ValueError example

```# Python code to demonstrate example of
# math.atanh() method with exception

# importing math module
import math

# number
x = -1
print("math.atanh(",x,"): ", math.atanh(x))
```

Output

```Traceback (most recent call last):
File "/home/main.py", line 9, in <odule>
print("math.atanh(",x,"): ", math.atanh(x))
ValueError: math domain error
```

TypeError example

```# Python code to demonstrate example of
# math.atanh() method with exception

# importing math module
import math

# number
x = "2"
print("math.atanh(",x,"): ", math.atanh(x))
```

Output

```Traceback (most recent call last):
File "/home/main.py", line 9, in <module>
print("math.atanh(",x,"): ", math.atanh(x))
TypeError: a float is required
```

Preparation