cmath是用於複數數學的Python 內置模塊。 cmath模塊具有方法tanh(),該方法返回傳遞給它的複數的雙曲正切值。
用法: cmath.tanh(Z)
參數:它僅需要一個參數,即需要為其計算雙曲正切的數字。
返回:返回一個複數,該複數是傳遞的數字的雙曲正切值。
範例1:
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.tanh(1 + 5j))
輸出:
(1.2407479829240697-0.18610947764730415j)
範例2:在此示例中,傳遞了實數,但返回的結果仍然是複數。
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.tanh(1))
輸出:
(0.7615941559557649+0j)
範例3:在此示例中,沒有傳遞參數,在這種情況下將拋出TypeError
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.tanh())
輸出:
TypeError:tanh() takes exactly one argument (0 given)
相關用法
- Python Wand function()用法及代碼示例
- Python oct()用法及代碼示例
- Python id()用法及代碼示例
- Python hex()用法及代碼示例
- Python now()用法及代碼示例
- Python ord()用法及代碼示例
- Python sum()用法及代碼示例
- Python map()用法及代碼示例
- Python tell()用法及代碼示例
- Python cmp()用法及代碼示例
- Python dir()用法及代碼示例
- Python int()用法及代碼示例
- Python str()用法及代碼示例
- Python cmath.sin()用法及代碼示例
- Python Wand arc()用法及代碼示例
- Python seek()用法及代碼示例
- Python strftime()用法及代碼示例
注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – cmath.tanh() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。