def translation_length(self): #UHP r""" For hyperbolic elements, return the translation length; otherwise, raise a ``ValueError``. EXAMPLES:: sage: UHP = HyperbolicPlane().UHP() sage: UHP.get_isometry(matrix(2,[2,0,0,1/2])).translation_length() 2*arccosh(5/4) :: sage: H = UHP.isometry_from_fixed_points(-1,1) sage: p = UHP.get_point(exp(i*7*pi/8)) sage: Hp = H(p) sage: bool((UHP.dist(p, Hp) - H.translation_length()) < 10**-9) True """ d = sqrt(self._matrix.det()**2) tau = sqrt((self._matrix / sqrt(d)).trace()**2) if self.classification() in [ 'hyperbolic', 'orientation-reversing hyperbolic' ]: return 2 * arccosh(tau / 2) raise TypeError( "translation length is only defined for hyperbolic transformations" )
def _dist_points(self, p1, p2): r""" Compute the distance between two points in the Upper Half Plane using the hyperbolic metric. INPUT: - ``p1``, ``p2`` -- the coordinates of the points EXAMPLES:: sage: HyperbolicPlane().UHP()._dist_points(4.0*I, I) 1.38629436111989 """ num = (real(p2) - real(p1))**2 + (imag(p2) - imag(p1))**2 denom = 2 * imag(p1) * imag(p2) if denom == 0: return infinity return arccosh(1 + num / denom)
def _dist_points(self, p1, p2): r""" Compute the distance between two points in the Upper Half Plane using the hyperbolic metric. INPUT: - ``p1``, ``p2`` -- the coordinates of the points EXAMPLES:: sage: HyperbolicPlane().UHP()._dist_points(4.0*I, I) 1.38629436111989 """ num = (real(p2) - real(p1))**2 + (imag(p2) - imag(p1))**2 denom = 2 * imag(p1) * imag(p2) if denom == 0: return infinity return arccosh(1 + num/denom)
def translation_length(self): #UHP r""" For hyperbolic elements, return the translation length; otherwise, raise a ``ValueError``. EXAMPLES:: sage: UHP = HyperbolicPlane().UHP() sage: UHP.get_isometry(matrix(2,[2,0,0,1/2])).translation_length() 2*arccosh(5/4) :: sage: H = UHP.isometry_from_fixed_points(-1,1) sage: p = UHP.get_point(exp(i*7*pi/8)) sage: Hp = H(p) sage: bool((UHP.dist(p, Hp) - H.translation_length()) < 10**-9) True """ d = sqrt(self._matrix.det()**2) tau = sqrt((self._matrix / sqrt(d)).trace()**2) if self.classification() in ['hyperbolic', 'oriention-reversing hyperbolic']: return 2 * arccosh(tau/2) raise TypeError("translation length is only defined for hyperbolic transformations")