all Python 3cmathfunction
cmath.cos()
trigonometry
The cosine of a complex argument; cos(i·x) equals cosh(x), so it can be arbitrarily large.
Syntax
cmath.cos(z)
Even for a real input the answer is complex and often carries a negative zero: cos(0) prints as (1-0j). That -0j equals zero, and cos(0) == 1 is True, but the printed text is confusing and breaks string comparisons in tests. Use math.cos for real angles; cmath is for genuinely complex arguments.
Examples
import cmath
print(cmath.cos(0), cmath.cos(0) == 1) # → (1-0j) True
print(cmath.cos(1j)) # → (1.5430806348152437-0j) — это cosh(1)
See also
Open in the full glossarydocs.python.orgReport an inaccuracy