Beispiel #1
0
    def create_key_and_extra_args(self,
                                  gens,
                                  check_integral=True,
                                  check_rank=True,
                                  check_is_ring=True,
                                  is_maximal=None,
                                  allow_subfield=False):
        if allow_subfield:
            raise NotImplementedError(
                "the allow_subfield parameter is not supported yet")
        if len(gens) == 0:
            raise ValueError("gens must span an order over ZZ")

        from sage.all import Sequence
        gens = Sequence(gens)

        K = gens.universe()
        from sage.rings.number_field.order import is_NumberFieldOrder
        if is_NumberFieldOrder(K):
            K = K.number_field()
        gens = frozenset([K(g) for g in gens])
        return (K, gens), {
            "check_integral": check_integral,
            "check_rank": check_rank,
            "check_is_ring": check_is_ring,
            "is_maximal": is_maximal
        }
Beispiel #2
0
    def global_height(self, prec=None):
        r"""
        Returns the logarithmic height of the point.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number

        EXAMPLES::

            sage: P.<x,y>=AffineSpace(QQ,2)
            sage: Q=P(41,1/12)
            sage: Q.global_height()
            3.71357206670431

        ::

            sage: P=AffineSpace(ZZ,4,'x')
            sage: Q=P(3,17,-51,5)
            sage: Q.global_height()
            3.93182563272433

        ::

            sage: R.<x>=PolynomialRing(QQ)
            sage: k.<w>=NumberField(x^2+5)
            sage: A=AffineSpace(k,2,'z')
            sage: A([3,5*w+1]).global_height(prec=100)
            2.4181409534757389986565376694

        .. TODO::

            p-adic heights

            add heights to integer.pyx and remove special case
        """
        if self.domain().base_ring() == ZZ:
            if prec is None:
                R = RealField()
            else:
                R = RealField(prec)
            H = max([
                self[i].abs() for i in range(
                    self.codomain().ambient_space().dimension_relative())
            ])
            return (R(max(H, 1)).log())
        if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(
                self.domain().base_ring()):
            return (max([
                self[i].global_height(prec) for i in range(
                    self.codomain().ambient_space().dimension_relative())
            ]))
        else:
            raise NotImplementedError(
                "Must be over a Numberfield or a Numberfield Order")
Beispiel #3
0
    def global_height(self, prec=None):
        r"""
        Returns the absolute logarithmic height of the point.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number.

        EXAMPLES::

            sage: P.<x,y,z> = ProjectiveSpace(QQ,2)
            sage: Q = P.point([4, 4, 1/30])
            sage: Q.global_height()
            4.78749174278205

        ::

            sage: P.<x,y,z> = ProjectiveSpace(ZZ,2)
            sage: Q = P([4, 1, 30])
            sage: Q.global_height()
            3.40119738166216

        ::

            sage: R.<x> = PolynomialRing(QQ)
            sage: k.<w> = NumberField(x^2+5)
            sage: A = ProjectiveSpace(k, 2, 'z')
            sage: A([3, 5*w+1, 1]).global_height(prec=100)
            2.4181409534757389986565376694

        ::

            sage: P.<x,y,z> = ProjectiveSpace(QQbar,2)
            sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1])
            sage: Q.global_height()
            0.549306144334055

        ::

            sage: K = UniversalCyclotomicField()
            sage: P.<x,y,z> = ProjectiveSpace(K,2)
            sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)])
            sage: Q.global_height()
            1.38629436111989
        """
        K = self.codomain().base_ring()
        if K in _NumberFields or is_NumberFieldOrder(K):
            P = self
        else:
            try:
                P = self._number_field_from_algebraics()
            except TypeError:
                raise TypeError("must be defined over an algebraic field")
        return(max([P[i].global_height(prec=prec) for i in range(self.codomain().ambient_space().dimension_relative()+1)]))
Beispiel #4
0
    def global_height(self, prec=None):
        r"""
        Return the absolute logarithmic height of the point.

        This function computes the maximum of global height of each
        component point in the product. Global height of component
        point is computed using function for projective point.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number.

        EXAMPLES::

            sage: PP = ProductProjectiveSpaces(QQ, [2,2], 'x')
            sage: Q = PP([1, 7, 5, 18, 2, 3])
            sage: Q.global_height()
            1.94591014905531

        ::

            sage: PP = ProductProjectiveSpaces(ZZ, [1,1], 'x')
            sage: A = PP([-30, 2, 1, 6])
            sage: A.global_height()
            3.40119738166216

        ::

            sage: R.<x> = PolynomialRing(QQ)
            sage: k.<w> = NumberField(x^2 + 5)
            sage: PP = ProductProjectiveSpaces(k, [1, 2], 'y')
            sage: Q = PP([3, 5*w+1, 1, 7*w, 10])
            sage: Q.global_height()
            2.30258509299405

        ::

            sage: PP = ProductProjectiveSpaces(QQbar, [1, 1], 'x')
            sage: Q = PP([1, QQbar(sqrt(2)), QQbar(5^(1/3)), QQbar(3^(1/3))])
            sage: Q.global_height()
            0.536479304144700
        """
        K = self.codomain().base_ring()
        if K not in NumberFields(
        ) and not is_NumberFieldOrder(K) and K != QQbar:
            raise TypeError(
                "must be over a number field or a number field order or QQbar")

        n = self.codomain().ambient_space().num_components()
        return max(self[i].global_height(prec=prec) for i in range(n))
Beispiel #5
0
    def global_height(self, prec=None):
        r"""
        Returns the logarithmic height of the point.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number

        EXAMPLES::

            sage: P.<x,y>=AffineSpace(QQ,2)
            sage: Q=P(41,1/12)
            sage: Q.global_height()
            3.71357206670431

        ::

            sage: P=AffineSpace(ZZ,4,'x')
            sage: Q=P(3,17,-51,5)
            sage: Q.global_height()
            3.93182563272433

        ::

            sage: R.<x>=PolynomialRing(QQ)
            sage: k.<w>=NumberField(x^2+5)
            sage: A=AffineSpace(k,2,'z')
            sage: A([3,5*w+1]).global_height(prec=100)
            2.4181409534757389986565376694

        .. TODO::

            p-adic heights

            add heights to integer.pyx and remove special case
        """
        if self.domain().base_ring() == ZZ:
            if prec is None:
                R = RealField()
            else:
                R = RealField(prec)
            H = max([self[i].abs() for i in range(self.codomain().ambient_space().dimension_relative())])
            return R(max(H, 1)).log()
        if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(self.domain().base_ring()):
            return max(
                [self[i].global_height(prec) for i in range(self.codomain().ambient_space().dimension_relative())]
            )
        else:
            raise NotImplementedError("Must be over a Numberfield or a Numberfield Order")
Beispiel #6
0
    def global_height(self, prec=None):
        r"""
        Returns the logarithmic height of the points. Must be over `\ZZ` or `\QQ`.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number

        EXAMPLES::

            sage: P.<x,y,z>=ProjectiveSpace(QQ,2)
            sage: Q=P.point([4,4,1/30])
            sage: Q.global_height()
            4.78749174278205

        ::

            sage: P.<x,y,z>=ProjectiveSpace(ZZ,2)
            sage: Q=P([4,1,30])
            sage: Q.global_height()
            3.40119738166216

        ::

            sage: R.<x>=PolynomialRing(QQ)
            sage: k.<w>=NumberField(x^2+5)
            sage: A=ProjectiveSpace(k,2,'z')
            sage: A([3,5*w+1,1]).global_height(prec=100)
            2.4181409534757389986565376694

        .. TODO::

            p-adic heights

            add heights to integer.pyx and remove special case
        """
        if self.domain().base_ring() == ZZ:
            if prec is None:
                R = RealField()
            else:
                R = RealField(prec)
            H=R(0)
            return(R(max([self[i].abs() for i in range(self.codomain().ambient_space().dimension_relative()+1)])).log())
        if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(self.domain().base_ring()):
            return(max([self[i].global_height(prec) for i in range(self.codomain().ambient_space().dimension_relative()+1)]))
        else:
            raise NotImplementedError("Must be over a Numberfield or a Numberfield Order")
Beispiel #7
0
    def global_height(self, prec=None):
        r"""
        Returns the maximum of the absolute logarithmic heights of the coefficients
        in any of the coordinate functions of this map.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number.

        .. TODO::

            Add functionality for `\QQbar`, implement function to convert
            the map defined over `\QQbar` to map over a number field.

        EXAMPLES::

            sage: P1xP1.<x,y,u,v> = ProductProjectiveSpaces([1, 1], ZZ)
            sage: H = End(P1xP1)
            sage: f = H([x^2*u, 3*y^2*v, 5*x*v^2, y*u^2])
            sage: f.global_height()
            1.60943791243410

        ::

            sage: u = QQ['u'].0
            sage: R = NumberField(u^2 - 2, 'v')
            sage: PP.<x,y,a,b> = ProductProjectiveSpaces([1, 1], R)
            sage: H = End(PP)
            sage: O = R.maximal_order()
            sage: g = H([3*O(u)*x^2, 13*x*y, 7*a*y, 5*b*x + O(u)*a*y])
            sage: g.global_height()
            2.56494935746154
        """
        K = self.domain().base_ring()
        if K in NumberFields() or is_NumberFieldOrder(K):
            H = 0
            for i in range(self.domain().ambient_space().ngens()):
                C = self[i].coefficients()
                h = max(c.global_height(prec=prec) for c in C)
                H = max(H, h)
            return H
        elif K == QQbar:
            raise NotImplementedError("not implemented for QQbar")
        else:
            raise TypeError(
                "Must be over a Numberfield or a Numberfield Order or QQbar")
Beispiel #8
0
    def global_height(self, prec=None):
        r"""
        Returns the logarithmic height of the points.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number

        EXAMPLES::

            sage: P.<x,y,z>=ProjectiveSpace(QQ,2)
            sage: Q=P.point([4,4,1/30])
            sage: Q.global_height()
            4.78749174278205

        ::

            sage: P.<x,y,z>=ProjectiveSpace(ZZ,2)
            sage: Q=P([4,1,30])
            sage: Q.global_height()
            3.40119738166216

        ::

            sage: R.<x>=PolynomialRing(QQ)
            sage: k.<w>=NumberField(x^2+5)
            sage: A=ProjectiveSpace(k,2,'z')
            sage: A([3,5*w+1,1]).global_height(prec=100)
            2.4181409534757389986565376694

        """
        if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(self.domain().base_ring()):
            return(max([self[i].global_height(prec=prec) for i in range(self.codomain().ambient_space().dimension_relative()+1)]))
        else:
            raise TypeError("Must be over a Numberfield or a Numberfield Order")
    def global_height(self, prec=None):
        r"""
        Return the absolute logarithmic height of the point.

        INPUT:

        - ``prec`` -- desired floating point precision (default:
          default RealField precision).

        OUTPUT:

        - a real number.

        EXAMPLES::

            sage: P.<x,y,z> = ProjectiveSpace(QQ,2)
            sage: Q = P.point([4, 4, 1/30])
            sage: Q.global_height()
            4.78749174278205

        ::

            sage: P.<x,y,z> = ProjectiveSpace(ZZ,2)
            sage: Q = P([4, 1, 30])
            sage: Q.global_height()
            3.40119738166216

        ::

            sage: R.<x> = PolynomialRing(QQ)
            sage: k.<w> = NumberField(x^2+5)
            sage: A = ProjectiveSpace(k, 2, 'z')
            sage: A([3, 5*w+1, 1]).global_height(prec=100)
            2.4181409534757389986565376694

        ::

            sage: P.<x,y,z> = ProjectiveSpace(QQbar,2)
            sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1])
            sage: Q.global_height()
            0.549306144334055

        ::

            sage: K = UniversalCyclotomicField()
            sage: P.<x,y,z> = ProjectiveSpace(K,2)
            sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)])
            sage: Q.global_height()
            1.38629436111989

        TESTS::

            sage: P = ProjectiveSpace(QQ, 2)
            sage: P(1/1,2/3,5/8).global_height()
            3.17805383034795

            sage: x = polygen(QQ, 'x')
            sage: F.<u> = NumberField(x^3 - 5)
            sage: P = ProjectiveSpace(F, 2)
            sage: P(u,u^2/5,1).global_height()
            1.07295860828940
        """
        if prec is None:
            prec = 53
        K = self.codomain().base_ring()
        if K in _NumberFields or is_NumberFieldOrder(K):
            P = self
        else:
            try:
                P = self._number_field_from_algebraics()
            except TypeError:
                raise TypeError("must be defined over an algebraic field")
            else:
                K = P.codomain().base_ring()
        # first get rid of the denominators
        denom = lcm([xi.denominator() for xi in P])
        x = [xi * denom for xi in P]
        d = K.degree()
        if d == 1:
            height = max(abs(xi) for xi in x) / gcd(x)
            return height.log().n(prec=prec)

        finite = ~sum(K.ideal(xi) for xi in x).norm()
        infinite = prod(
            max(abs(xi.complex_embedding(prec, i)) for xi in x)
            for i in range(d))
        height = (finite * infinite)**(~d)
        return height.log()