📜  Python – cmath.cos()函数

📅  最后修改于: 2022-05-13 01:54:59.093000             🧑  作者: Mango

Python – cmath.cos()函数

cMath 模块包含许多用于复数数学运算的函数。 cmath.cos()函数返回复数的余弦值。此函数中传递的值可以是int、float复数

下面的例子说明了上述函数的使用:

示例 #1:在这个示例中,我们可以通过使用cmath 看到这一点。 cos ()方法,我们可以通过传递任何值来获取余弦的值。

Python3
# Python code to implement
# the cos()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.cos() method 
val = cmath.cos(3) 
    
print(val)


Python3
# Python code to implement
# the cos()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.cos() method 
val = cmath.cos(2 + 5j) 
    
print(val)


输出:

(-0.9899924966004454-0j)

示例 2:

Python3

# Python code to implement
# the cos()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.cos() method 
val = cmath.cos(2 + 5j) 
    
print(val)

输出:

(-30.88223531891674-67.47278844058752j)