Python math.sinh() Method

Musfirah Waseem Jan 30, 2023
  1. Syntax of Python math.sinh() Method
  2. Example 1: Use the math.sinh() Method in Python
  3. Example 2: Use the math.sinh() Method to Get Hyperbolic Sine of Degrees
  4. Example 3: TypeError When Using the math.sinh() Method
Python math.sinh() Method

Python math.sinh() method is an efficient way of calculating the hyperbolic sine of a number in radians. The input parameter must be in radians.

Syntax of Python math.sinh() Method

math.sinh(x)

Parameters

x Any positive or negative radian value to be operated on.

Return

This method returns a float value, from -1 to 1, representing the hyperbolic sine of x in radians.

Example 1: Use the math.sinh() Method in Python

import math

x = 1.654

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

x = 0

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

x = -34.5

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

x = math.pi

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

x = math.inf

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

Output:

The hyperbolic sine of 1.654 is 2.518283107292417.
The hyperbolic sine of 0 is 0.0.
The hyperbolic sine of -34.5 is -480982892772388.2.
The hyperbolic sine of 3.141592653589793 is 11.548739357257748.
The hyperbolic sine of inf is inf.

Note that the arguments can be in integers or floats. The values may either be positive or negative.

Example 2: Use the math.sinh() Method to Get Hyperbolic Sine of Degrees

import math

print("The hyperbolic sine of 30 degrees is ", math.sinh(math.radians(30)))

Output:

The hyperbolic sine of 30 degrees is  0.5478534738880397

We use these methods in mathematical computations related to geometry and have a certain application in astronomical computations.

Example 3: TypeError When Using the math.sinh() Method

import math

x = "h"

value = math.sinh(x)

print(f"The hyperbolic sine of {x} is {value}.")

Output:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    value=math.sinh(x)
TypeError: must be real number, not str

Note that a TypeError exception may occur if the argument value is not a number.

Musfirah Waseem avatar Musfirah Waseem avatar

Musfirah is a student of computer science from the best university in Pakistan. She has a knack for programming and everything related. She is a tech geek who loves to help people as much as possible.

LinkedIn

Related Article - Python Math