STINNER Victor <victor.stin...@haypocalc.com> added the comment: (-1)**.5 is the same than complex(-1,0)**.5, but it is computed differently than cmath.sqrt(-1).
-1.**0.5 computes: vabs = math.hypot(-1, 0) len = pow(vabs, 0.5) at = math.atan2(0, -1) phase = at * 0.5 return complex(len*math.cos(phase), len*math.sin(phase)) whereas cmath.sqrt(-1) computes: ax = math.fabs(-1) ay = math.fabs(0) ax /= 8. s = 2. * math.sqrt(ax + math.hypot(ax, ay/8.)) d = ay / (2.*s) return complex(d, math.copysign(s, 0)) Anyway, math.sqrt() and cmath.sqrt() are designed to be more precise than x**0.5. ---------- nosy: +haypo, mark.dickinson _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11658> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com