Python - AI 助手

Python cmath.atan() 函数



Python 的 cmath.atan() 函数返回一个数字的反正切值(以弧度表示)。

反正切定义为正切函数的反函数。反正切函数的定义域范围是 [-∞,∞],其值域以弧度表示。

语法

以下是 Python cmath.atan() 函数的语法:

cmath.atan(x)

参数

此函数包含数值。

返回值

此方法返回 x 的反正切值(以弧度表示)。

示例 1

在下面的示例中,我们使用了 Python cmath.atan() 函数来查找 '0'、'-1' 和 '1' 的反正切值。

import cmath
zero = cmath.atan(0)
neg_one = cmath.atan(-1)
pos_one = cmath.atan(1)
print("Arc Tangent value of 0:", zero)
print("Arc Tangent value of -1:", neg_one)
print("Arc Tangent value of 1:", pos_one)

输出

运行以上代码后,将产生以下结果:

Arc Tangent value of 0: 0j
Arc Tangent value of -1: (-0.7853981633974483+0j)
Arc Tangent value of 1: (0.7853981633974483+0j)

示例 2

在这里,我们使用 arc sine() 函数将非标准正切比作为参数传递。

import cmath
x = cmath.atan(0.234)
y = cmath.atan(-3.4)
print(x,y)

输出

如果我们编译上述程序,输出如下:

(0.2298640844033592+0j) (-1.2847448850775784+0j)

示例 3

在下面的示例中,我们使用 cmath.atan() 函数计算复数值。

import cmath
print(cmath.atan(2 + 3j))
print(cmath.atan(5 - 4j))

输出

运行以上代码后,我们将得到以下结果:

(1.4099210495965755+0.22907268296853878j)
(1.4483069952314644-0.09641562020299617j)
python_modules.htm
广告
© . All rights reserved.