| 1 | initial version |
The documentation does not specify it, but it is true. (It should be added to the documentation.)
When you call a.sqrt() first a square root x is computed, and then x = x._balanced_abs() is called.
def _balanced_abs(self):
"""
This function returns `x` or `-x`, whichever has a
positive representative in `-n/2 < x \leq n/2`.
This is used so that the same square root is always returned,
despite the possibly probabilistic nature of the underlying
algorithm.
"""
if self.lift() > self.__modulus.sageInteger >> 1:
return -self
else:
return self
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.