Python Glossary Русский

all Python 3cmathfunction

cmath.sin()

trigonometry

The sine of a complex argument. For imaginary numbers it grows without bound, unlike the real sine limited to [-1, 1].

Syntax

cmath.sin(z)

The familiar |sin x| ≤ 1 holds only for real x: sin(3j) has a modulus of about 10. Even for a real argument the answer is complex, and sin(pi) prints as (1.2246467991473532e-16-0j): an imaginary negative zero and a non-zero real part. Use math.sin for real angles and test for zero with isclose and abs_tol.

Examples

import cmath
print(cmath.sin(cmath.pi))  # → (1.2246467991473532e-16-0j)
print(round(abs(cmath.sin(3j)), 3))  # → 10.018
import cmath
print(cmath.isclose(cmath.sin(cmath.pi), 0, abs_tol=1e-9))  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy