Python - AI 助手

Python cmath.sinh() 函数



Python 的 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)
python_modules.htm
广告

© . All rights reserved.