runtime-height.txt

back to table · edit · history · where entries came from · files · download

12763 bytes, as of the version from 2026-11-20 07:17 (current). Recorded here, not run.

    def height(self, precision=None, normalised=True, algorithm='pari'):
        r"""Return the Néron-Tate canonical height of the point.

        INPUT:

        - ``self`` -- a point on an elliptic curve over a number field `K`

        - ``precision`` -- positive integer, or ``None`` (default). The
          precision in bits of the result. If ``None``, the default real
          precision is used.

        - ``normalised`` -- boolean. If ``True`` (default), the height is
          normalised to be invariant under extension of `K`. If ``False``,
          return this normalised height multiplied by the degree of `K`.

        - ``algorithm`` -- string; either ``'pari'`` (default) or ``'sage'``.
          If ``'pari'`` and the base field is `\QQ`, use the PARI library
          function; otherwise use the Sage implementation.

        OUTPUT:

        The rational number 0, or a nonnegative real number.

        There are two normalisations used in the literature, one of
        which is double the other. We use the larger of the two, which
        is the one appropriate for the BSD conjecture. This is
        consistent with [Cre1997]_ and double that of [Sil2009]_.

        See :wikipedia:`Néron-Tate height`.

        .. NOTE::

            The correct height to use for the regulator in the BSD
            formula is the non-normalised height.

        EXAMPLES::

            sage: E = EllipticCurve('11a'); E
            Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
            sage: P = E([5,5]); P
            (5 : 5 : 1)
            sage: P.height()
            0
            sage: Q = 5*P
            sage: Q.height()
            0

        ::

            sage: E = EllipticCurve('37a'); E
            Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
            sage: P = E([0,0])
            sage: P.height()
            0.0511114082399688
            sage: P.order()
            +Infinity
            sage: E.regulator()
            0.0511114082399688...

            sage: def naive_height(P):
            ....:     return log(RR(max(abs(P[0].numerator()), abs(P[0].denominator()))))
            sage: for n in [1..10]:
            ....:     print(naive_height(2^n*P)/4^n)
            0.000000000000000
            0.0433216987849966
            0.0502949347635656
            0.0511006335618645
            0.0511007834799612
            0.0511013666152466
            0.0511034199907743
            0.0511106492906471
            0.0511114081541082
            0.0511114081541180

        ::

            sage: E = EllipticCurve('4602a1'); E
            Elliptic Curve defined by y^2 + x*y  = x^3 + x^2 - 37746035*x - 89296920339
            over Rational Field
            sage: x = 77985922458974949246858229195945103471590
            sage: y = 19575260230015313702261379022151675961965157108920263594545223
            sage: d = 2254020761884782243
            sage: E([ x / d^2,  y / d^3 ]).height()
            86.7406561381275

        ::

            sage: E = EllipticCurve([17, -60, -120, 0, 0]); E
            Elliptic Curve defined by y^2 + 17*x*y - 120*y = x^3 - 60*x^2 over Rational Field
            sage: E([30, -90]).height()
            0

            sage: E = EllipticCurve('389a1'); E
            Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
            sage: P, Q = E(-1,1), E(0,-1)
            sage: P.height(precision=100)
            0.68666708330558658572355210295
            sage: (3*Q).height(precision=100)/Q.height(precision=100)
            9.0000000000000000000000000000
            sage: _.parent()
            Real Field with 100 bits of precision

        Canonical heights over number fields are implemented as well::

            sage: R.<x> = QQ[]
            sage: K.<a> = NumberField(x^3 - 2)                                          # needs sage.rings.number_field
            sage: E = EllipticCurve([a, 4]); E                                          # needs sage.rings.number_field
            Elliptic Curve defined by y^2 = x^3 + a*x + 4
             over Number Field in a with defining polynomial x^3 - 2
            sage: P = E((0,2))                                                          # needs sage.rings.number_field
            sage: P.height()                                                            # needs sage.rings.number_field
            0.810463096585925
            sage: P.height(precision=100)                                               # needs sage.rings.number_field
            0.81046309658592536863991810577
            sage: P.height(precision=200)                                               # needs sage.rings.number_field
            0.81046309658592536863991810576865158896130286417155832378086
            sage: (2*P).height() / P.height()                                           # needs sage.rings.number_field
            4.00000000000000
            sage: (100*P).height() / P.height()                                         # needs sage.rings.number_field
            10000.0000000000

        Setting ``normalised=False`` multiplies the height by the degree of `K`::

            sage: E = EllipticCurve('37a')
            sage: P = E([0,0])
            sage: P.height()
            0.0511114082399688
            sage: P.height(normalised=False)
            0.0511114082399688
            sage: K.<z> = CyclotomicField(5)                                            # needs sage.rings.number_field
            sage: EK = E.change_ring(K)                                                 # needs sage.rings.number_field
            sage: PK = EK([0,0])                                                        # needs sage.rings.number_field
            sage: PK.height()                                                           # needs sage.rings.number_field
            0.0511114082399688
            sage: PK.height(normalised=False)                                           # needs sage.rings.number_field
            0.204445632959875

        Some consistency checks::

            sage: E = EllipticCurve('5077a1')
            sage: P = E([-2,3,1])
            sage: P.height()
            1.36857250535393

            sage: EK = E.change_ring(QuadraticField(-3,'a'))                            # needs sage.rings.number_field
            sage: PK = EK([-2,3,1])                                                     # needs sage.rings.number_field
            sage: PK.height()                                                           # needs sage.rings.number_field
            1.36857250535393

            sage: # needs sage.rings.number_field
            sage: K.<i> = NumberField(x^2 + 1)
            sage: E = EllipticCurve(K, [0,0,4,6*i,0])
            sage: Q = E.lift_x(-9/4); Q
            (-9/4 : 27/8*i - 4 : 1)
            sage: Q.height()
            2.69518560017909
            sage: (15*Q).height() / Q.height()
            225.000000000000

            sage: E = EllipticCurve('37a')
            sage: P = E([0,-1])
            sage: P.height()
            0.0511114082399688
            sage: K.<a> = QuadraticField(-7)                                            # needs sage.rings.number_field
            sage: ED = E.quadratic_twist(-7)                                            # needs sage.rings.number_field
            sage: Q = E.isomorphism_to(ED.change_ring(K))(P); Q                         # needs sage.rings.number_field
            (0 : -7/2*a - 1/2 : 1)
            sage: Q.height()                                                            # needs sage.rings.number_field
            0.0511114082399688
            sage: Q.height(precision=100)                                               # needs sage.rings.number_field
            0.051111408239968840235886099757

        An example to show that the bug at :issue:`5252` is fixed::

            sage: E = EllipticCurve([1, -1, 1, -2063758701246626370773726978, 32838647793306133075103747085833809114881])
            sage: P = E([-30987785091199, 258909576181697016447])
            sage: P.height()
            25.8603170675462
            sage: P.height(precision=100)
            25.860317067546190743868840741
            sage: P.height(precision=250)
            25.860317067546190743868840740735110323098872903844416215577171041783572513
            sage: P.height(precision=500)
            25.8603170675461907438688407407351103230988729038444162155771710417835725129551130570889813281792157278507639909972112856019190236125362914195452321720

            sage: P.height(precision=100) == P.non_archimedean_local_height(prec=100)+P.archimedean_local_height(prec=100)
            True

        An example to show that the bug at :issue:`8319` is fixed (correct height when the curve is not minimal)::

            sage: E = EllipticCurve([-5580472329446114952805505804593498080000,-157339733785368110382973689903536054787700497223306368000000])
            sage: xP = 204885147732879546487576840131729064308289385547094673627174585676211859152978311600/23625501907057948132262217188983681204856907657753178415430361
            sage: P = E.lift_x(xP)
            sage: P.height()
            157.432598516754
            sage: Q = 2*P
            sage: Q.height() # long time (4s)
            629.730394067016
            sage: Q.height()-4*P.height() # long time
            0.000000000000000

        An example to show that the bug at :issue:`12509` is fixed (precision issues)::

            sage: # needs sage.rings.number_field
            sage: x = polygen(QQ)
            sage: K.<a> = NumberField(x^2 - x - 1)
            sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688]
            sage: E = EllipticCurve(v)
            sage: P = E([72*a - 509/5,  -682/25*a - 434/25])
            sage: P.height()
            1.38877711688727
            sage: (2*P).height()/P.height()
            4.00000000000000
            sage: (2*P).height(precision=100)/P.height(precision=100)
            4.0000000000000000000000000000
            sage: (2*P).height(precision=1000)/P.height(precision=1000)
            4.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

        This shows that the bug reported at :issue:`13951` has been fixed::

            sage: E = EllipticCurve([0,17])
            sage: P1 = E(2,5)
            sage: P1.height()
            1.06248137652528
            sage: F = E.change_ring(QuadraticField(-3, 'a'))                            # needs sage.rings.number_field
            sage: P2 = F([2,5])                                                         # needs sage.rings.number_field
            sage: P2.height()                                                           # needs sage.rings.number_field
            1.06248137652528

        This shows that the bug reported at :issue:`36834` (incorrect
        value when the model is not integral) has been fixed::

            sage: # needs sage.rings.number_field
            sage: K.<a> = NumberField(x^2 - 84131656042917)
            sage: E = EllipticCurve(K, [0, 0, 0, -5482707841/48, -244634179112639/864])
            sage: P = E(349189/12, 1/2*a)
            sage: P.height()
            10.4560438181991
            sage: [(n*P).height()/P.height() for n in [2,3,4,5]]
            [4.00000000000000, 9.00000000000000, 16.0000000000000, 25.0000000000000]

        """
        if self.has_finite_order():
            return QQ(0)

        E = self.curve()
        K = E.base_ring()

        if precision is None:
            precision = RealField().precision()

        known_prec = -1
        try:
            height = self.__height
            known_prec = height.prec()
            if known_prec > precision:
                height = RealField(precision)(height)
        except AttributeError:
            pass

        if known_prec < precision:
            if algorithm == 'pari' and K is QQ:
                Emin = E.minimal_model()
                iso = E.isomorphism_to(Emin)
                P = iso(self)
                h = Emin.pari_curve().ellheight(P, precision=precision)
                height = RealField(precision)(h)
            else:
                height = (self.non_archimedean_local_height(prec=precision)
                          + self.archimedean_local_height(prec=precision))

        # The cached height is the one that is independent of the base field.
        self.__height = height
        if not normalised:
            height *= K.degree()
        return height