Python cmath 模块的 cmath.sinh() 函数返回复数的双曲正弦。
双曲正弦函数表示为 sinh(x)。指定反正弦函数的数学函数计算正弦值,即复数或 x 的实数。
双曲正弦函数的数学表示定义为 -
sinh(x) = (ex - e-x)/ 2
其中 e(e=2.71828) 是自然对数的底数。此函数相对于原点对称:sinh(-x) = -sinh(X)。
语法
以下是 Python cmath.sinh() 函数的基本语法 -
cmath.sinh(x)
参数
此函数接受单个实数,为此我们需要找到双曲正弦作为参数。
返回值
此函数返回给定复数的双曲正弦。
示例 1
在下面的示例中,我们使用 cmath.sinh() 函数计算正复数的双曲正弦 -
import cmath
x = 2+3j
result = cmath.sinh(x)
print(result)
输出
获得的输出如下 -
(-3.59056458998578+0.5309210862485197j)
示例 2
当我们向 cmath.sinh() 函数传递一个分数值时,它会返回一个复数 −
import cmath
from fractions import Fraction
x = Fraction(4, -10)
result = cmath.sinh(x)
print(result)
输出
以下是上述代码的输出 -
(-0.4107523258028155+0j)
示例 3
在下面的示例中,我们使用 cmath.sinh() 函数检索负数的双曲正弦 -
import cmath
x = -0.7
result = cmath.sinh(x)
print(result)
输出
我们将得到以下输出 -
(-0.7585837018395334+0j)
示例 4
在以下示例中,我们将创建一个循环,以使用 cmath.sinh() 函数创建双曲正弦值。此循环遍历列表中的每个值。
import cmath
values = [2.0, 4.0, 6.0]
for x in values:
result = cmath.sinh(x)
print("sinh({}) = {}".format(x, result))
输出
我们将得到如下所示的输出 -
sinh(2.0) = (3.626860407847019+0j)
sinh(4.0) = (27.28991719712775+0j)
sinh(6.0) = (201.71315737027922+0j)
sinh(4.0) = (27.28991719712775+0j)
sinh(6.0) = (201.71315737027922+0j)