This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients JBernardo, mark.dickinson, vstinner
Date 2011-03-24.02:51:20
SpamBayes Score 0.019070001
Marked as misclassified No
Message-id <1300935081.12.0.299799534417.issue11658@psf.upfronthosting.co.za>
In-reply-to
Content
(-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.
History
Date User Action Args
2011-03-24 02:51:21vstinnersetrecipients: + vstinner, mark.dickinson, JBernardo
2011-03-24 02:51:21vstinnersetmessageid: <1300935081.12.0.299799534417.issue11658@psf.upfronthosting.co.za>
2011-03-24 02:51:20vstinnerlinkissue11658 messages
2011-03-24 02:51:20vstinnercreate