Python cmath 模块的 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)
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)
(1.4483069952314644-0.09641562020299617j)