On this page
cmath.sqrt
Prev: cmath.sinh | Up: cmath | Next: cmath.tan
Rel: cmath.acos, cmath.acosh, cmath.asin, cmath.asinh
Ref: docs.python.org — cmath.sqrt
Tags: #public #python3 #stdlib #cmath
Import
import cmath
from cmath import sqrt
Signature & Overview
cmath.sqrt(z, /)
Return the square root of z.
Usage
import cmath
assert cmath.sqrt(-4) == 2j
assert cmath.isclose(cmath.sqrt(2j), 1 + 1j)
Gotchas
- Handles negative reals cleanly (unlike
math.sqrt(-4)which raisesValueError).
REPL Inspect
from cmath import sqrt
help(sqrt)
Linked from
Related notes
- tuts/python3/stdlib_module/cmath/sinh Linked here; links to this page; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/tan Linked here; links to this page; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/cmath/acos Linked here; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/acosh Linked here; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/asin Linked here; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/asinh Linked here; shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/atan shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/atanh shared tags: #cmath, #stdlib
- tuts/python3/stdlib_module/cmath/cos shared tags: #cmath, #stdlib