runtime-archimedean_local_height.txt

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

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

    def archimedean_local_height(self, v=None, prec=None, weighted=False):
        """
        Compute the local height of ``self`` at the archimedean place `v`.

        INPUT:

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

        - ``v`` -- a real or complex embedding of K, or None (default).
          If `v` is a real or complex embedding, return the local
          height of ``self`` at `v`. If `v` is None, return the total
          archimedean contribution to the global height.

        - ``prec`` -- integer or ``None`` (default). The precision of the
          computation. If ``None``, the precision is deduced from `v`

        - ``weighted`` -- boolean. If ``False`` (default), the height is
          normalised to be invariant under extension of `K`. If ``True``,
          return this normalised height multiplied by the local degree
          if `v` is a single place, or by the degree of `K` if `v` is ``None``.

        OUTPUT:

        A real number. The normalisation is twice that in Silverman's
        paper [Sil1988]_. Note that this local height depends on the
        model of the curve.

        ALGORITHM:

        See [Sil1988]_, Section 4.

        EXAMPLES:

        Examples 1, 2, and 3 from [Sil1988]_::

            sage: # needs sage.rings.number_field
            sage: K.<a> = QuadraticField(-2)
            sage: E = EllipticCurve(K, [0,-1,1,0,0]); E
            Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 over Number Field
             in a with defining polynomial x^2 + 2 with a = 1.414213562373095?*I
            sage: P = E.lift_x(2 + a); P
            (a + 2 : -2*a - 2 : 1)
            sage: P.archimedean_local_height(K.places(prec=170)[0]) / 2
            0.45754773287523276736211210741423654346576029814695

            sage: # needs sage.rings.number_field
            sage: x = polygen(ZZ, 'x')
            sage: K.<i> = NumberField(x^2 + 1)
            sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E
            Elliptic Curve defined by y^2 + 4*y = x^3 + 6*i*x
             over Number Field in i with defining polynomial x^2 + 1
            sage: P = E((0,0))
            sage: P.archimedean_local_height(K.places()[0]) / 2
            0.510184995162373

            sage: Q = E.lift_x(-9/4); Q                                                 # needs sage.rings.number_field
            (-9/4 : 27/8*i - 4 : 1)
            sage: Q.archimedean_local_height(K.places()[0]) / 2                         # needs sage.rings.number_field
            0.654445619529600

        An example over the rational numbers::

            sage: E = EllipticCurve([0, 0, 0, -36, 0])
            sage: P = E([-3, 9])
            sage: P.archimedean_local_height()
            1.98723816350773

        Local heights of torsion points can be nonzero (unlike the
        global height)::

            sage: # needs sage.rings.number_field
            sage: K.<i> = QuadraticField(-1)
            sage: E = EllipticCurve([0, 0, 0, K(1), 0])
            sage: P = E(i, 0)
            sage: P.archimedean_local_height()
            0.346573590279973

        TESTS:

        See :issue:`12509`::

            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.archimedean_local_height()
            -0.220660795546828

        See :issue:`19276`::

            sage: # needs sage.rings.number_field
            sage: K.<a> = NumberField(x^2 - x - 104)
            sage: E = EllipticCurve([1, a - 1, 1, -816765673272*a - 7931030674178, 1478955604013312315*a + 14361086227143654561])
            sage: P = E(5393511/49*a + 52372721/49 , -33896210324/343*a - 329141996591/343 )
            sage: P.height()
            0.974232017827741

        See :issue:`29966`::

            sage: # needs sage.rings.number_field
            sage: K.<a> = NumberField(x^3 - x^2 - 6*x + 2)
            sage: E = EllipticCurve([1, -a^2 + 2*a + 4, 0, -6056450500590472699700624*a^2 - 11239394326797569935861742*a + 4241549693833829432516231,
            ....:                    1904879037869682826729875958079326124520*a^2 + 3535022146945771697732350459284777382011*a - 1334055169621036218710397707677347972626])
            sage: P = E([1033399668533*a^2 + 1917754693229*a - 723726883800 , 12536493059202326563*a^2 + 23264879148900575548*a - 8779756111574815918 , 1])
            sage: P.height()
            0.297318833424763
            sage: (2*P).height() / P.height()
            4.00000000000000
            sage: P.height(200)
            0.29731883342476341806143743594519935578696537745294661858984
            sage: (2*P).height(200) / P.height(200)
            4.0000000000000000000000000000000000000000000000000000000000
        """
        from sage.rings.number_field.number_field import refine_embedding
        from sage.rings.real_mpfr import RealField
        from sage.rings.complex_mpfr import ComplexField
        from sage.rings.infinity import Infinity

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

        if v is None:

            if prec is None:
                prec = 53
            if K is QQ:
                v = K.embeddings(RR)[0]
                h = self.archimedean_local_height(v, prec+10)
            else:
                r1, r2 = K.signature()
                pl = K.places()
                h = (sum(self.archimedean_local_height(pl[i], prec+10, weighted=False)
                         for i in range(r1))
                     + 2 * sum(self.archimedean_local_height(pl[i], prec+10, weighted=False)
                               for i in range(r1, r1 + r2)))
                if not weighted:
                    h /= K.degree()
            return RealField(prec)(h)

        prec_v = v.codomain().prec()
        if prec is None:
            prec = prec_v
        if K is QQ:
            v = K.embeddings(RealField())[0]
        v_inf = refine_embedding(v, Infinity)
        v_is_real = v_inf(K.gen()).imag().is_zero()

        # Find a suitable working precision.  See trac#29666 for an
        # example where 100 extra bits is not enough when the
        # discriminant is ~1e-92, but this code uses a working
        # precision of 333 and gets it right.

        D = v_inf(E.discriminant())

        if D.abs().real_number(RealField()).round():
            extra_prec = 100
        else:  # then |D| is small
            extra_prec = 10 + (1/D).abs().real_number(RealField()).round().nbits()

        working_prec = prec + extra_prec
        RC = RealField(working_prec) if v_is_real else ComplexField(working_prec)
        # print("Using working precision {}, |D| = {}".format(working_prec, RC(D).abs()))

        # NB We risk losing much precision if we compute the embedding
        # of K into RR or CC to some precision and then apply that to
        # elements of K.  Instead we map elements of K into AA or Qbar
        # (with infinite precision) and then trim back to RR or CC.

        x = RC(v_inf(self[0]))
        b2, b4, b6, b8 = (RC(v_inf(b)) for b in E.b_invariants())

        # The following comes from Silverman Theorem 4.2.  Silverman
        # uses decimal precision d, so his term (5/3)d =
        # (5/3)*(log(2)/log(10))*prec = 0.5017*prec, which we round
        # up.  The rest of the expression was wrongly transcribed in
        # Sage versions <5.6 (see #12509).

        H = max(RC(4).abs(), b2.abs(), 2*b4.abs(), 2*b6.abs(), b8.abs())
        absdisc = RC(v_inf(E.discriminant())).abs()
        adl3 = 0 if absdisc >= 1 else absdisc.log() / 3
        nterms = int(math.ceil(0.51*working_prec + 0.5 + 0.75 * (7 + 4*H.log()/3 - adl3).log()))

        b2p = b2 - 12
        b4p = b4 - b2 + 6
        b6p = b6 - 2*b4 + b2 - 4
        b8p = b8 - 3*b6 + 3*b4 - b2 + 3

        fz = lambda T: 1 - T**2 * (b4 + T*(2*b6 + T*b8))
        fzp = lambda T: 1 - T**2 * (b4p + T*(2*b6p + T*b8p))
        fw = lambda T: T*(4 + T*(b2 + T*(2*b4 + T*b6)))
        fwp = lambda T: T*(4 + T*(b2p + T*(2*b4p + T*b6p)))

        if abs(x) >= .5:
            t = 1/x
            beta = True
        else:
            t = 1/(x+1)
            beta = False
        lam = -t.abs().log()
        mu = 0
        four_to_n = QQ(1)

        for n in range(nterms):
            if beta:
                w = fw(t)
                z = fz(t)
                if abs(w) <= 2 * z.abs():
                    mu += four_to_n * z.abs().log()
                    t = w/z
                else:
                    mu += four_to_n * (z+w).abs().log()
                    t = w/(z+w)
                    beta = not beta
            else:
                w = fwp(t)
                z = fzp(t)
                if abs(w) <= 2 * z.abs():
                    mu += four_to_n * z.abs().log()
                    t = w/z
                else:
                    mu += four_to_n * (z-w).abs().log()
                    t = w/(z-w)
                    beta = not beta
            four_to_n >>= 2

        h = RealField(prec)(lam + mu/4)
        if weighted and not v_is_real:
            h *= 2
        return h