Friday, September 26, 2025
HomeLanguagesPython – cmath.tanh() function

Python – cmath.tanh() function

cmath is Python built-in module that is used for complex number mathematics. cmath module has a method tanh() that returns hyperbolic  tangent of the complex number passed to it.

Syntax: cmath.tanh(Z)

Parameter: It requires only one parameter i.e the number for which hyperbolic tangent needs to be calculated.

Return: Returns a complex number that is the hyperbolic tangent of the number passed.

Example 1: 

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tanh(1 + 5j))


Output:

(1.2407479829240697-0.18610947764730415j)

Example 2: In this example real number is passed but the returned result is still a complex number.

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tanh(1))


Output:

(0.7615941559557649+0j)

Example 3: In this example no argument is passed in this case TypeError will be thrown

Python3




# Import the Library
import cmath 
  
# Printing the result
print (cmath.tanh())


Output:

TypeError: tanh() takes exactly one argument (0 given)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32321 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6683 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6795 POSTS0 COMMENTS
Ted Musemwa
7071 POSTS0 COMMENTS
Thapelo Manthata
6756 POSTS0 COMMENTS
Umr Jansen
6762 POSTS0 COMMENTS