Ticket #13615: ell_curve_isogeny_split.patch

File ell_curve_isogeny_split.patch, 145.1 KB (added by cremona, 6 years ago)
  • sage/schemes/elliptic_curves/ell_curve_isogeny.py

    # HG changeset patch
    # User Kiminori Tsukazaki <kiminori.t@gmail.com>
    # Date 1374408138 -3600
    # Node ID 68e26eb8c8d77af38c65cbe6f745919dc5852853
    # Parent  0f8fd922eaed351e39f913f1317d319dcceb4c01
    [mq]: isogs
    
    diff --git a/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/sage/schemes/elliptic_curves/ell_curve_isogeny.py
    a b  
    38773877    return (pre_isom, post_isom, E1pr, E2pr, ker_poly)
    38783878
    38793879
    3880 ##########################################################################
    3881 # The following section is all about computing l-isogenies, where l is
    3882 # a prime.  The genus 0 cases `l` = 2, 3, 5, 7 and 13 are
    3883 # implemented over any field of characteristic not 2, 3 or `l`; over
    3884 # `\QQ` the "sporadic" cases `l` = 11, 17, 19, 37, 43, 67 or 163 with
    3885 # only finitely many `j`-invariants each. are also implemented.
    3886 ##########################################################################
    3887 
    3888 @cached_function
    3889 def Fricke_polynomial(l):
    3890     r"""
    3891     Fricke polynomial for ``l`` =2,3,5,7,13.
    3892 
    3893     For these primes (and these only) the modular curve `X_0(l)` has
    3894     genus zero, and its field is generated by a single modular
    3895     function called the Fricke module (or Hauptmodul), `t`.  There is
    3896     a classical choice of such a generator `t` in each case, and the
    3897     `j`-function is a rational function of `t` of degree `l+1` of the
    3898     form `P(t)/t` where `P` is a polynomial of degree `l+1`.  Up to
    3899     scaling, `t` is determined by the condition that the ramification
    3900     points above `j=\infty` are `t=0` (with ramification degree `1`)
    3901     and `t=\infty` (with degree `l`).  The ramification above `j=0`
    3902     and `j=1728` may be seen in the factorizations of `j(t)` and
    3903     `k(t)` where `k=j-1728`.
    3904 
    3905     OUTPUT:
    3906 
    3907     The polynomial `P(t)` as an element of `\ZZ[t]`.
    3908 
    3909     TESTS::
    3910 
    3911         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import Fricke_polynomial
    3912         sage: Fricke_polynomial(2)
    3913         t^3 + 48*t^2 + 768*t + 4096
    3914         sage: Fricke_polynomial(3)
    3915         t^4 + 36*t^3 + 270*t^2 + 756*t + 729
    3916         sage: Fricke_polynomial(5)
    3917         t^6 + 30*t^5 + 315*t^4 + 1300*t^3 + 1575*t^2 + 750*t + 125
    3918         sage: Fricke_polynomial(7)
    3919         t^8 + 28*t^7 + 322*t^6 + 1904*t^5 + 5915*t^4 + 8624*t^3 + 4018*t^2 + 748*t + 49
    3920         sage: Fricke_polynomial(13)
    3921         t^14 + 26*t^13 + 325*t^12 + 2548*t^11 + 13832*t^10 + 54340*t^9 + 157118*t^8 + 333580*t^7 + 509366*t^6 + 534820*t^5 + 354536*t^4 + 124852*t^3 + 15145*t^2 + 746*t + 13
    3922     """
    3923     Zt = PolynomialRing(ZZ,'t')
    3924     t = Zt.gen()
    3925     if l==2: return (t+16)**3
    3926     elif l==3: return (t+3)**3*(t+27)
    3927     elif l==5: return (t**2+10*t+5)**3
    3928     elif l==7: return (t**2+5*t+1)**3 * (t**2+13*t+49)
    3929     elif l==13: return (t**2+5*t+13)*(t**4+7*t**3+20*t**2+19*t+1)**3
    3930     else:
    3931         raise ValueError, "The only genus zero primes are 2, 3, 5, 7 or 13."
    3932 
    3933 @cached_function
    3934 def Fricke_module(l):
    3935     r"""
    3936     Fricke module for ``l`` =2,3,5,7,13.
    3937 
    3938     For these primes (and these only) the modular curve `X_0(l)` has
    3939     genus zero, and its field is generated by a single modular
    3940     function called the Fricke module (or Hauptmodul), `t`.  There is
    3941     a classical choice of such a generator `t` in each case, and the
    3942     `j`-function is a rational function of `t` of degree `l+1` of the
    3943     form `P(t)/t` where `P` is a polynomial of degree `l+1`.  Up to
    3944     scaling, `t` is determined by the condition that the ramification
    3945     points above `j=\infty` are `t=0` (with ramification degree `1`)
    3946     and `t=\infty` (with degree `l`).  The ramification above `j=0`
    3947     and `j=1728` may be seen in the factorizations of `j(t)` and
    3948     `k(t)` where `k=j-1728`.
    3949 
    3950     OUTPUT:
    3951 
    3952     The rational function `P(t)/t`.
    3953 
    3954     TESTS::
    3955 
    3956         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import Fricke_module
    3957         sage: Fricke_module(2)
    3958         (t^3 + 48*t^2 + 768*t + 4096)/t
    3959         sage: Fricke_module(3)
    3960         (t^4 + 36*t^3 + 270*t^2 + 756*t + 729)/t
    3961         sage: Fricke_module(5)
    3962         (t^6 + 30*t^5 + 315*t^4 + 1300*t^3 + 1575*t^2 + 750*t + 125)/t
    3963         sage: Fricke_module(7)
    3964         (t^8 + 28*t^7 + 322*t^6 + 1904*t^5 + 5915*t^4 + 8624*t^3 + 4018*t^2 + 748*t + 49)/t
    3965         sage: Fricke_module(13)
    3966         (t^14 + 26*t^13 + 325*t^12 + 2548*t^11 + 13832*t^10 + 54340*t^9 + 157118*t^8 + 333580*t^7 + 509366*t^6 + 534820*t^5 + 354536*t^4 + 124852*t^3 + 15145*t^2 + 746*t + 13)/t
    3967     """
    3968     try:       
    3969         t = PolynomialRing(QQ,'t').gen()
    3970         return Fricke_polynomial(l) / t
    3971     except ValueError:
    3972         raise ValueError, "The only genus zero primes are 2, 3, 5, 7 or 13."
    3973 
    3974 @cached_function
    3975 def Psi(l, use_stored=True):
    3976     r"""
    3977     Generic kernel polynomial for genus one primes.
    3978 
    3979     For each of the primes `l` for which `X_0(l)` has genus zero
    3980     (namely `l=2,3,5,7,13`), we may define an elliptic curve `E_t`
    3981     over `\QQ(t)`, with coefficients in `\ZZ[t]`, which has good
    3982     reduction except at `t=0` and `t=\infty` (which lie above
    3983     `j=\infty`) and at certain other values of `t` above `j=0` when
    3984     `l=3` (one value) or `l\equiv1\pmod{3}` (two values) and above
    3985     `j=1728` when `l=2` (one value) or `l\equiv1 \pmod{4}` (two
    3986     values).  (These exceptional values correspond to endomorphisms of
    3987     `E_t` of degree `l`.)  The `l`-division polynomial of `E_t` has a
    3988     unique factor of degree `(l-1)/2` (or 1 when `l=2`), with
    3989     coefficients in `\ZZ[t]`, which we call the Generic Kernel
    3990     Polynomial for `l`.  These are used, by specialising `t`, in the
    3991     function :meth:`isogenies_prime_degree_genus_0`, which also has to
    3992     take into account the twisting factor between `E_t` for a specific
    3993     value of `t` and the short Weierstrass form of an elliptic curve
    3994     with `j`-invariant `j(t)`.  This enables the computation of the
    3995     kernel polynomials of isogenies without having to compute and
    3996     factor division polynomials.
    3997 
    3998     All of this data is quickly computed from the Fricke modules, except
    3999     that for `l=13` the factorization of the Generic Division Polynomial
    4000     takes a long time, so the value have been precomputed and cached; by
    4001     default the cached values are used, but the code here will recompute
    4002     them when ``use_stored`` is ``False``, as in the doctests.
    4003 
    4004     INPUT:
    4005 
    4006     - ``l`` -- either 2, 3, 5, 7, or 13.
    4007 
    4008     - ``use_stored`` (boolean, default True) -- If True, use
    4009       precomputed values, otherwise compute them on the fly.
    4010 
    4011     .. note:: 
    4012    
    4013        This computation takes a negligible time for `l=2,3,5,7'
    4014        but more than 100s for `l=13`.  The reason
    4015        for allowing dynamic computation here instead of just using
    4016        precomputed values is for testing.
    4017 
    4018     TESTS::
    4019 
    4020         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import Fricke_module, Psi
    4021         sage: assert Psi(2, use_stored=True) == Psi(2, use_stored=False)
    4022         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
    4023         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
    4024         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
    4025         sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
    4026     """
    4027     if not l in [2,3,5,7,13]:
    4028         raise ValueError, "Genus zero primes are 2, 3, 5, 7 or 13."
    4029 
    4030     R = PolynomialRing(ZZ,2,'Xt')
    4031     X,t = R.gens()
    4032 
    4033     if use_stored:
    4034         if l==2:
    4035             return X + t + 64
    4036         if l==3:
    4037             return X + t + 27
    4038         if l==5:
    4039             return X**2 + 2*X*(t**2 + 22*t + 125)+ (t**2 + 22*t + 89) * (t**2 + 22*t + 125)
    4040         if l==7:
    4041             return (X**3 + 3*(t**2 + 13*t + 49)*X**2
    4042                     + 3*(t**2 + 13*t + 33)*(t**2 + 13*t + 49)*X
    4043                     + (t**2 + 13*t + 49)*(t**4 + 26*t**3 + 219*t**2 + 778*t + 881))
    4044         if l==13:
    4045             return (t**24 + 66*t**23 + 2091*t**22 + 6*X*t**20 + 42582*t**21 + 330*X*t**19 + 627603*t**20 + 8700*X*t**18 + 7134744*t**19 + 15*X**2*t**16 + 146886*X*t**17 + 65042724*t**18 + 660*X**2*t**15 + 1784532*X*t**16 + 487778988*t**17 + 13890*X**2*t**14 + 16594230*X*t**15 + 3061861065*t**16 + 20*X**3*t**12 + 186024*X**2*t**13 + 122552328*X*t**14 + 16280123754*t**15 + 660*X**3*t**11 + 1774887*X**2*t**12 + 735836862*X*t**13 + 73911331425*t**14 + 10380*X**3*t**10 + 12787272*X**2*t**11 + 3646188342*X*t**12 + 287938949178*t**13 + 15*X**4*t**8 + 102576*X**3*t**9 + 71909658*X**2*t**10 + 15047141292*X*t**11 + 964903805434*t**12 + 330*X**4*t**7 + 707604*X**3*t**8 + 321704316*X**2*t**9 + 51955096824*X*t**10 + 2781843718722*t**11 + 3435*X**4*t**6 + 3582876*X**3*t**7 + 1155971196*X**2*t**8 + 150205315932*X*t**9 + 6885805359741*t**10 + 6*X**5*t**4 + 21714*X**4*t**5 + 13632168*X**3*t**6 + 3343499244*X**2*t**7 + 362526695094*X*t**8 + 14569390179114*t**9 + 66*X**5*t**3 + 90660*X**4*t**4 + 39215388*X**3*t**5 + 7747596090*X**2*t**6 + 725403501318*X*t**7 + 26165223178293*t**8 + 336*X**5*t**2 + 255090*X**4*t**3 + 84525732*X**3*t**4 + 14206132008*X**2*t**5 + 1189398495432*X*t**6 + 39474479008356*t**7 + X**6 + 858*X**5*t + 472143*X**4*t**2 + 132886992*X**3*t**3 + 20157510639*X**2*t**4 + 1569568001646*X*t**5 + 49303015587132*t**6 + 1014*X**5 + 525954*X**4*t + 144222780*X**3*t**2 + 21320908440*X**2*t**3 + 1622460290100*X*t**4 + 49941619724976*t**5 + 272259*X**4 + 96482100*X**3*t + 15765293778*X**2*t**2 + 1260038295438*X*t**3 + 39836631701295*t**4 + 29641924*X**3 + 7210949460*X**2*t + 686651250012*X*t**2 + 23947528862166*t**3 + 1506392823*X**2 + 231462513906*X*t + 10114876838391*t**2 + 35655266790*X + 2644809206442*t + 317295487717)
    4046 # The coefficients for l=13 are:
    4047 # X**6: 1
    4048 # X**5: (6) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13)
    4049 # X**4: (3) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13) * (5*t**4 + 55*t**3 + 260*t**2 + 583*t + 537)
    4050 # X**3: (4) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13)**2 * (5*t**6 + 80*t**5 + 560*t**4 + 2214*t**3 + 5128*t**2 + 6568*t + 3373)
    4051 # X**2: (3) * (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**2 * (5*t**8 + 110*t**7 + 1045*t**6 + 5798*t**5 + 20508*t**4 + 47134*t**3 + 67685*t**2 + 54406*t + 17581)
    4052 # X**1: (6) * (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**3 * (t**10 + 27*t**9 + 316*t**8 + 2225*t**7 + 10463*t**6 + 34232*t**5 + 78299*t**4 + 122305*t**3 + 122892*t**2 + 69427*t + 16005)
    4053 # X**0: (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**3 * (t**14 + 38*t**13 + 649*t**12 + 6844*t**11 + 50216*t**10 + 271612*t**9 + 1115174*t**8 + 3520132*t**7 + 8549270*t**6 + 15812476*t**5 + 21764840*t**4 + 21384124*t**3 + 13952929*t**2 + 5282630*t + 854569)
    4054 #
    4055 
    4056     # Here the generic kernel polynomials are actually calculated:
    4057     j = Fricke_module(l)
    4058     k = j-1728
    4059     from sage.misc.all import prod
    4060     f = prod( [p for p,e in j.factor() if e==3]
    4061              +[p for p,e in k.factor() if e==2])
    4062     A4 = -3*t**2*j*k // f**2
    4063     A6 = -2*t**3*j*k**2 // f**3
    4064     E = EllipticCurve([0,0,0,A4,A6])
    4065     assert E.j_invariant() == j
    4066     return E.division_polynomial(l,X).factor()[0][0]
    4067 
    4068 
    4069 def isogenies_prime_degree_genus_0(E, l=None):
    4070     """
    4071     Returns list of ``l`` -isogenies with domain ``E``.
    4072 
    4073     INPUT:
    4074 
    4075     - ``E`` -- an elliptic curve.
    4076 
    4077     - ``l`` -- either None or 2, 3, 5, 7, or 13.
    4078 
    4079     OUTPUT:
    4080 
    4081     (list) When ``l`` is None a list of all isogenies of degree 2, 3,
    4082     5, 7 and 13, otherwise a list of isogenies of the given degree.
    4083 
    4084     .. note::
    4085 
    4086        This function would normally be invoked indirectly via
    4087        ``E.isogenies_prime_degree(l)``, which automatically calls the
    4088        appropriate function.
    4089 
    4090     EXAMPLES::
    4091    
    4092         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_prime_degree_genus_0
    4093         sage: E = EllipticCurve([0,12])
    4094         sage: isogenies_prime_degree_genus_0(E, 5)
    4095         []
    4096 
    4097         sage: E = EllipticCurve('1450c1')   
    4098         sage: isogenies_prime_degree_genus_0(E)   
    4099         [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 300*x - 1000 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 5950*x - 182250 over Rational Field]
    4100 
    4101         sage: E = EllipticCurve('50a1')   
    4102         sage: isogenies_prime_degree_genus_0(E) 
    4103         [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 - x - 2 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 126*x - 552 over Rational Field,
    4104         Isogeny of degree 5 from Elliptic Curve defined by y^2 + x*y + y = x^3 - x - 2 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 76*x + 298 over Rational Field]
    4105     """
    4106     if not l in [2, 3, 5, 7, 13, None]:
    4107         raise ValueError, "Isogenies must be of degree 2, 3, 5, 7 or 13."
    4108     F = E.base_ring()
    4109     j = E.j_invariant()
    4110     if F.characteristic() in [2, 3, l]:
    4111         raise NotImplementedError, "2, 3, 5, 7 and 13-isogenies are not yet implemented in characteristic 2 and 3, and when the characteristic is the same as the degree of the isogeny."
    4112     if l==2:
    4113         return isogenies_2(E)
    4114     if l==3:
    4115         return isogenies_3(E)
    4116     if j==F(0):
    4117         if l==5:
    4118             return isogenies_5_0(E)
    4119         if l==7:
    4120             return isogenies_7_0(E)
    4121         if l==13:
    4122             return isogenies_13_0(E)
    4123     if j==F(1728):
    4124         if l==5:
    4125             return isogenies_5_1728(E)
    4126         if l==7:
    4127             return isogenies_7_1728(E)
    4128         if l==13:
    4129             return isogenies_13_1728(E)
    4130  
    4131     if l != None:
    4132         R = PolynomialRing(F,'t')
    4133         t = R.gen()
    4134         f = R(Fricke_polynomial(l))
    4135         t_list = (f-j*t).roots(multiplicities=False)
    4136         t_list.sort()
    4137         # The generic kernel polynomial applies to a standard curve
    4138         # E_t with the correct j-invariant; we must compute the
    4139         # appropriate twising factor to scale X by:
    4140         c4, c6 = E.c_invariants()
    4141         T = c4/(3*c6)
    4142         jt = Fricke_module(l)
    4143         kt = jt-1728
    4144         from sage.misc.all import prod
    4145         psi = Psi(l)
    4146         X = t
    4147         f = R(prod( [p for p,e in jt.factor() if e==3]
    4148                  +[p for p,e in kt.factor() if e==2]))
    4149         kernels = [R(psi(X*T*(j-1728)*t0/f(t0),t0)) for t0 in t_list]
    4150         kernels = [ker.monic() for ker in kernels]
    4151         E1 = EllipticCurve([-27*c4,-54*c6])
    4152         w = E.isomorphism_to(E1)
    4153         model = "minimal" if F is QQ else None
    4154         isogs = [E1.isogeny(kernel=ker, model=model) for ker in kernels]
    4155         [isog.set_pre_isomorphism(w) for isog in isogs]
    4156         return isogs
    4157 
    4158     if l == None:
    4159         return sum([isogenies_prime_degree_genus_0(E, l) for l in [2,3,5,7,13]],[])
    4160 
    4161 
    4162 # The following is data to be used in isogenies_sporadic_Q. Over Q
    4163 # there are only finitely many j-invariants of curves with l-isogenies
    4164 # where l is not equal to 2, 3, 5, 7 or 13. In these cases l is equal
    4165 # to 11, 17, 19, 37, 43, 67 or 163. We refer to these l as "sporadic".
    4166 #
    4167 # isog_table is indexed by the possible sporadic (l,j) pairs and lists
    4168 # ((a4,a6),f) where (a4,a6) are the invariants of a short Weierstrass
    4169 # model of one curve with that j-invariant,and f is the factor of
    4170 # degree (l-1)/2 of the l-division polynomial of that curve. Then
    4171 # whenever we have a curve of that j-invariant, we can compute the
    4172 # corresponding l-isogeny by just scaling f by the right twisting
    4173 # factor and using the result as a kernel-polynomial.
    4174 
    4175 # Sample code to precompute this data.  Note that working over ZZ
    4176 # instead of QQ is a lot faster (in Sage 4.2):
    4177 #
    4178 #sage: j = -297756989/2; l = 17
    4179 #sage: E = EllipticCurve(ZZ,EllipticCurve(j=j).short_weierstrass_model().ainvs())
    4180 #sage: E.division_polynomial(l,polygen(ZZ)).factor()[1][0].coefficients()
    4181 #
    4182 #sage: j = -884736000; l = 43
    4183 #sage: E = EllipticCurve(ZZ,EllipticCurve(j=j).short_weierstrass_model().ainvs())
    4184 #sage: E.division_polynomial(l,polygen(ZZ)).factor()[1][0].coefficients()
    4185 
    4186 
    4187 isog_table = dict()
    4188 
    4189 isog_table[(11,QQ('-32768'))] = ([-9504, 365904], [1294672896, -92835072, 1463616, 7920, -264, 1])
    4190 
    4191 isog_table[(11,QQ('-121'))] = ([-3267, -280962], [1480352841, -56169531, -2829222, 10890, 429, 1])
    4192 
    4193 isog_table[(11,QQ('-24729001'))] = ([-38907, -2953962], [-20349931239, -424530315, -134838, 53658, 429, 1])
    4194 
    4195 isog_table[(17,QQ('-297756989/2'))] = ([-3940515, 3010787550], [-6458213126940667330314375, 34699336325466068070000, -72461450055340471500, 68342601718080000, -15140380554450, -25802960400, 23981220, -8160, 1])
    4196 
    4197 isog_table[(17,QQ('-882216989/131072'))] = ([-856035, -341748450], [103687510635057329105625, 961598491955315190000, 1054634146768300500, -6553122389064000, -14554350284850, -2046589200, 13185540, 8160, 1])
    4198 
    4199 isog_table[(19,QQ('-884736'))] = ([-608, 5776], [-34162868224, -8540717056, 6405537792, -1123778560, 84283392, -2033152, -92416, 6992, -152, 1])
    4200 
    4201 isog_table[(37,QQ('-9317'))] = ([-10395, 444150],[-38324677699334121599624973029296875, -17868327793500376961572310472656250, 2569568362004197901139023084765625, -95128267987528547588017818750000, -822168183291347061312510937500, 134395594560592096297190625000, -2881389756919344324888937500, -2503855007083401977250000, 922779077075655997443750, -11503912310262102937500, -18237870962450291250, 1457822151548910000, -10087015556047500, -13677678063000, 490243338900, -2461460400, 5198445, -4410, 1])
    4202 
    4203 isog_table[(37,QQ('-162677523113838677'))] = ([-269675595, -1704553285050], [-31653754873248632711650187487655160190139073510876609346911928661154296875/37, -1469048260972089939455942042937882262144594798448952781325533511718750, -1171741935131505774747142644126089902595908234671576131857702734375, -574934780393177024547076427530739751753985644656221274606250000, -193516922725803688001809624711400287605136013195315374687500, -47085563820928456130325308223963045033502182349693125000, -8472233937388712980597845725196873697064639957437500, -1124815211213953261752081095348112305023653750000, -105684015609077608033913080859605951322531250, -5911406027236569746089675554748135312500, 22343907270397352965399097794968750, 43602171843758666292581116410000, 5054350766002463251474186500, 350135768194635636171000, 16633063574896677300, 549939627039600, 12182993865, 163170, 1])
    4204 
    4205 isog_table[(43,QQ('-884736000'))] = ([-13760, 621264],[-1961864562041980324821547425314935668736, 784270445793223959453256359333693751296, -120528107728500223255333768387027271680, 10335626145581464192664472924270362624, -568426570575654606865505142156820480, 21261993723422650574629752537088000, -544630471727787626557612832587776, 8870521306520473088172555763712, -54993059067301585878494740480, -1434261324709904840432549888, 50978938193065926383894528, -845761855773797582372864, 8627493611216601088000, -48299605284169187328, -32782260293713920, 3415534989828096, -34580115625984, 199359712512, -730488128, 1658080, -2064, 1])
    4206 
    4207 isog_table[(67,QQ('-147197952000'))] = ([-117920, 15585808], [426552448394636714720553816389274308035895411389805883034985546818882031845376, -55876556222880738651382959148329502876096075327084935039031884373558741172224, 3393295715290183821010552313572221545212247684503012173117764703828786020352, -125729166452196578653551230178028570067747190427221869867485520072257044480, 3121342502030777257351089270834971957072933779704445667351054593298530304, -52544031605544530265465344472543470442324636919759253720520768014516224, 532110915869155495738137756847596184665209453108323879594125221167104, -399031158106622651277981701966309467713625045637309782055519780864, -101914346170769215732007802723651742508893380955930030421292613632, 2296526155500449624398016447877283594461904009374321659789443072, -31950871094301541469458501953701002806003991982768349794795520, 329792235011603804948028315065667439678526339671142107709440, -2655636715955021784085217734679612378726442691190553837568, 16825164648840434987220620681420687654501026066872664064, -81705027839007003131400500185224450729843244954288128, 273656504606483403474090105104132405333665144373248, -320807702482945680116212224172370503903312084992, -3166683390779345463318656135338172047199043584, 27871349428383710305216046431806697565585408, -132774697798318602604125735604528772808704, 436096215568182871014215818309741314048, -964687143341252402362763535357837312, 942144169187362941776488535425024, 2794850106281773765892648206336, -17236916236678037389276086272, 50979778712911923486851072, -105035658611718440992768, 161833913559276412928, -188675698610077696, 163929317513984, -102098677888, 42387952, -10184, 1])
    4208 
    4209 isog_table[(163,QQ('-262537412640768000'))] = ([-34790720, 78984748304], [11937033609701771608400008302859181021419097217821452062564326844817505228663098831008549807845273606080544999996020379100442085010011180910986311230744539492209201267851475053850145465949031314131282944262561686476431332761205504055553653209756637748416809823347727611717499380045401030656, -195130071447306655273524569473852352290010571088570084255929596426827972913675959924834214553822436039185267072655230231264389277855757579340840680919752147359277865429131554516271296434318501723193704667609983954393732283396979741770275596479169906167026623493287956522391758781645062144, 1427502734760154784443139998885173873805698542265553947708985997014264802221336771918193375050938963016560184673026895611200993837000754187703921657388546609660768979949394789838000919808563779734300559653270446650866261801622261730386746625133970663551831816512698564779980290036596736, -5599207432852992026535855102327743354503965526118767584653806869099469434869389394471452436350209911401734358692516268244363981178003440912521398279843764610451103952982463228121628686179444592844803463454880601969041617668281227800515971090274318968755339891485627349912827843313664, 7275289443663173375117187980461451723630939807433676133488193878209459535146604043302393215325736700753114238886326617501903060793779318898498537340122928915051396994852249905774785383484964157718761647679761326405167986820403416875550489904598260809039588027484880575324789669888, 53852767252251176711316610474871670511285949778037067647446607721301053062542360857644949076379793988972999080753585666268471181395581176311086709516236139859119228114940726664020344711163961450649040900179940667704933096423082541578086102752168151408016128448757608609516355584, -441024601763314150109608522830440149169771622404264936395215000306188259683627792348927267455527449622616337194882061278315837263834842622422058957336768392927319786456429412773335490683756389242358011775192147290260088212928183893496023497385031567935590156495818971603271680, 1923729652470036657640234466480856403679261373466564217770510758620007251234737653848912112257887106718711179570266106782165127910894792855741763009046440188368346201617134183692667813264354753020558715833289878752200363206184231817927249353441775148372373391040829093576704, -6174291905252822700639099970860178217904525535465573253756653994759145320917644436646210500761314537511653465341404223911052812759676375813287317189557074876672717009913962857515263325087926781282727274494599622098970326546685474959128901831166082055481492871737587531776, 15963605433939241348215386312076502855685142708851007052060264896693306401589916424547272907372369971200908960298559196028000249867821387055883338894215055448441454208145184664251082508258481820123154014612667230187589409024581605410594578299015578613903351914203971584, -34687777075075826936035422448136670540047824478867437603900549472003349053758981331083701038247602826434094223697740838012005963350495346494192086319952577715870471857062004211165110944749546489357024333327851492892063261902845789001287880518909468079710544890691584, 64935614565701660925102862834870557968917923758048315817978089985628103203452108238400473842703675144415856702414743965076964752315718880263247146806212144113325233966196430978981658754610129252819800656290540439882400228191972297000590950499022332532802841477120, -106450113192928986500166510746460290010686605565802553549898115364953461571938149159855780359758326598170956839310849727549767334328481520722457671184262149140997347199434067316119593873464084542168958564857207310255104210252802288265107074620056433232296542208, 154588468341182819097156049664780175805765082709542906853062319968823210709884467518965950031344875777123989196305422245441384128571495551803479155842444104959551491130118809781140758556182128829570214830557657320822341658937375265326185627024588353675722752, -200559814675071715715147513664537685696543665835231560123119674695431140901874837885144270078673500682009909076723885595600964688749788075855566556738418513204701882392037282897429720984011892144438563658741417367819609826485149957684720592798005782904832, 233913230287794067984901680255098952718268709897211662836962202594844321932231309396660409956864579218254273924904394011519168528453166798219739516110916032144001430976170021740673624911101610999174313953331179592523559209806130064362331035786304028672, -246353703535830799051965068435640665615241585380168769205605419959931340172791084855084136413845436489354260626697043416419953596294256639939636661074827002386688825389366314922889935515780006872313799807871034941783710991661439846743406825846079488, 234982742638283161239147075499923192184558615040750093346909554959954534765162320677404212311317141015056956519607730625264033505832417237335526289717986324622989530401755659861160278474288472483456460761582961131223878005034852988312569782468608, -203278213565303083958289848507904983111914464281937008996800600743049033135780053019308180654889993715847194782810638377233384956677984229396984592095978852141937402724743415866647478390224972086303117541277057454016741537801255285401042550784, 159421011266364165773350759598961923468646295930442671951663830439105229019095602850806206849694626149081055860876320252885592409781300283802068036284087012054926328984117466238728138017296876920468741929209733382315316048593848804000661504, -113020918346823224387675962727710849438448560054728764538889949910907956081636084818673918939857811981198128625134001275445247927733612860826192033364144709296859805908448480126055187856540001252440723696556907592809391568682658983575552, 71945777186858148520189111385851657591994785437936790663752048596268908397761761228530149720647914698227096033298596468433406211022425872184679773706985835273196359946527329295352840585601589987654250252509940697181497393634479177728, -40553506248279853197899380016510447069205875473858373944916667311741237594752103405195544436215283638784303466518029972315361472909380024525230365389883507930702477745185560842399992120410631726800835247081534888734998176190169088, 19639696188973552762819015734509385187497753279018359326954702329472344393424778261565226791972589248949076879073752940457430177635689762236418319921157145929450429275277598105096782299310906043071624518383647513981402864418816, -7557145635717782395604678688732309739123765964398036300935902895029921544449817739871127195837816246027098669576710973724603305169613035210748794125702623638061784934800621663541549758981147547220745886014319375033833619456, 1657074863449131529294393850366914004166071540911557375298352670995793916631379837217699843183161870412953109096989706473414891817476345269315000071815674837414249807862563049048940888990780356828116926372826050377809920, 594537607406738614488647166334439665406200193881374352383582637957395810395355986219181323336507140663007282377906531198753011484726171889166159296232442266402815351908351664480142997422997116094990105400004717838336, -1063381335685557601789471169771716160614658527547206527560235661204306306147122486589145738731952820149525220010993135210540125800587297277176980780550749659568216404307556497848427558893515024809067113577642459136, 866504016710397283549081797838552191017551170056714418172658679484342314216337494688411296133019156758665490378562995489461120013841310945167448587950589192882728019730184100760635093600626150305226434294054912, -544456451437710104677464982275658569122639544706468906698603670935572135268235880234260773620839923609980624261711876187191086008709319550421652238153751371247896403810296918434808016324776218527300472274944, 291391938923983436973777049837536733140215048414562274102609644110225500962890424001140034799254161420207705596799832439286323749581485058440291289292376834767289200150488260103720502388531610043446984704, -137669336373928330264003425607593379960726875901008061728935571651808147336578784033262243606118618305155146994101199276509296485578362621442124562716722538959248783675765430495753630524650420015464448, 58305039769563586190846386880024028458953483779423358562963969531061253550565868881984384427294827940260948562007946246585988242539388915757370599713569828414708265704775708180369817440224330907648, -22263674613297409152475382098514675408629524088165884591926938276387287183647211206514841583522457779552325379611699721363009213935995055122374833256328128159685068070573439567341889102047870976, 7659525572873653643686667682470156611730287715779213959462404612107764289631014622079262434509991525269350939684751076168111178931547830737285816290499346814316593688339716060537705476390912, -2356369509601030092354164626593105564281508081035914666378162646456624099153984023946457193322861690246151591627985138670141283491665875837349056368982626874320059053912723460560567402496, 636306064623878566247238117586667093960745761448319133509756604897082306674457051834692637631208787669480579961449146859307914219525683813169045631019945325543755784485150162136596480, -144354698667964959131302121388611435649331689922451077357726958728526160763985021377919777057073652734054824995380136026354322489788621439866623621032883911971992887755746217820160, 24121955586756417060840806312875152536841537469465641066665477185642959713399102667004561835703554642486033432650174169972215286732914841507194929969333501923213681889898397696, -1062982554332400020436047718307967606435230424325029173087078414691100152298424407470637592479633445244263771003475924500470457802708388802132021409732119617604143984672768, -1289959173517591900879403877417447464323361120695839905879179383576917611515563011791770601288187258710836960962551744314331281738572022125094897455138775637822772609024, 713094034093241133139975542207369737377005379966568397923649557581354608722973890056780743426440880397949894405054289149004564424971813787111450018625163532324306944, -254627379967901645020979419858451704766383325190491161773871149760504423262065255127251316663797380198173202687716259997416292667070368594859769612820620832145408, 73141763506085097918144459824978126154049420184880822723900482544151820781804249152002290712777719695036970656528265835764223704583688284269989955443519127552, -17838537225679516940483486695156689114251551141417084228356667456567223074797422210814066353881812352204911178711536306766419580650031647883778868599848960, 3732949472404613028683276858400771022649020140479952475050562287824228475488013407594597423014344735572239887680502683815016952233794807477380489150464, -658090831088275932021697572468169724648153295038942023393017242911882324988827102897240587742441233130939688197251981440661637431663180512231424000, 91044773494274344573228085560493548892450695165631132364575161840790371925870648417274049055693061297980952723608086693629684733411639066361856, -7206875978668204173369106020317806614830036116031258178074085756310402308591937698714169573782276745187407867676712962154996289706219536384, -819751497058465540849522914081577930969395072622202448379227754265195552229316711754131018363430793506957620878700584807196119659446272, 524492219141524596329431820120551446539246304466694008535436881375050446937946483408452355745347329681867559263476448413099237572608, -144831995016562693238485974645571530330971707229081912571899541756458417275452663670185243929333997861822834344607487043313860608, 29914869637979316056234691641068533246353548074478964560456384907200155525359490145390698951538414992573246875654471802683392, -5051703199007242317980870828294675665554938059871421101373455640671888804716466166733214891733545898164243959713215021056, 704266224450794229753813389400889235502895246267920454892105495898823500254340026026030392861415807391779452916596736, -77090914220067457257437168730743598007998214624866646138957596697882331770536104168830311427039146990575867133952, 5185529715527985800186976473360862373518426289807725150611458977619779754244941008386724289180811582624497664, 253997773097193639890870939442154039645526260966991421810387625142025920490445698037959549218977356972032, -167663051891371188948811201282888303918118872228509878481620659513761819092806840088343319460416847872, 37111139278046773379558801627698801653586358926939257719148812112681156722739468064234356797865984, -6094794232647488071603134809336879629321484740792083961518604911291776122012806633249006682112, 837291566508665017874331015912241564512130987193765470835615200761060354034220082158108672, -100296887606046826616864046733353580911852480578758327196473644505408067503452896362496, 10671531126308719182671886696772003009468978048122050876385337250105289881860177920, -1017660211057522997139542974021461951590281854561469513981031668621068390629376, 87341651749945752980300268787472991750253192293865191008561736741703122944, -6755055811837604655292473395831392832731215030180150346004905802596352, 470435697396489049890276884918878813522261509046808135502735081472, -29431936259973770189795237369002643735145492537132570738950144, 1647955729708147681608319291051493831298410618099083509760, -82151504501901440318090519089275042334656836617109504, 3621394962905672351516373383975280471835697741824, -139946424433346723333934826799658073276284928, 4689146702972667351768128807176661303296, -134326059738838559898371882636836864, 3230090486862617839209120497664, -63628315178835325152092160, 992573003659549935360, -11668560578458368, 95539651616, -472048, 1])
    4210 
    4211 
    4212 
    4213 def isogenies_sporadic_Q(E, l=None):
    4214     """
    4215     Returns list of ``l`` -isogenies with domain ``E`` (defined over `\QQ`).
    4216 
    4217     Returns a list of sporadic l-isogenies from E (l = 11, 17, 19, 37,
    4218     43, 67 or 163). Only for elliptic curves over `\QQ`.
    4219 
    4220     INPUT:
    4221 
    4222     - ``E`` -- an elliptic curve defined over `\QQ`.
    4223 
    4224     - ``l`` -- either None or a prime number.
    4225 
    4226     OUTPUT:
    4227 
    4228     (list) If ``l`` is None, a list of all isogenies with domain ``E``
    4229     and of degree 11, 17, 19, 37, 43, 67 or 163; otherwise a list of
    4230     isogenies of the given degree.
    4231 
    4232     .. note::
    4233 
    4234        This function would normally be invoked indirectly via
    4235        ``E.isogenies_prime_degree(l)``, which automatically calls the appropriate
    4236        function.
    4237 
    4238     EXAMPLES::
    4239 
    4240         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_sporadic_Q                                                                       
    4241         sage: E = EllipticCurve('121a1')   
    4242         sage: isogenies_sporadic_Q(E, 11)
    4243         [Isogeny of degree 11 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 30*x - 76 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 305*x + 7888 over Rational Field]
    4244         sage: isogenies_sporadic_Q(E, 13)
    4245         []
    4246         sage: isogenies_sporadic_Q(E, 17)
    4247         []
    4248         sage: isogenies_sporadic_Q(E)   
    4249         [Isogeny of degree 11 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 30*x - 76 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 305*x + 7888 over Rational Field]
    4250          
    4251         sage: E = EllipticCurve([1, 1, 0, -660, -7600])   
    4252         sage: isogenies_sporadic_Q(E, 17)
    4253         [Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 660*x - 7600 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 878710*x + 316677750 over Rational Field]
    4254         sage: isogenies_sporadic_Q(E)   
    4255         [Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 660*x - 7600 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 878710*x + 316677750 over Rational Field]
    4256         sage: isogenies_sporadic_Q(E, 11)
    4257         []
    4258        
    4259         sage: E = EllipticCurve([0, 0, 1, -1862, -30956])   
    4260         sage: isogenies_sporadic_Q(E, 11)
    4261         []
    4262         sage: isogenies_sporadic_Q(E, 19)
    4263         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
    4264         sage: isogenies_sporadic_Q(E)   
    4265         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
    4266 
    4267         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
    4268         sage: E.conductor()
    4269         19600
    4270         sage: isogenies_sporadic_Q(E,37)
    4271         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
    4272 
    4273         sage: E = EllipticCurve([1, 1, 0, -25178045, 48616918750])
    4274         sage: E.conductor()                                       
    4275         148225
    4276         sage: isogenies_sporadic_Q(E,37)
    4277         [Isogeny of degree 37 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 25178045*x + 48616918750 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 970*x - 13075 over Rational Field]
    4278 
    4279         sage: E = EllipticCurve([-3440, 77658])         
    4280         sage: E.conductor()                   
    4281         118336
    4282         sage: isogenies_sporadic_Q(E,43)       
    4283         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
    4284 
    4285         sage: E = EllipticCurve([-29480, -1948226])     
    4286         sage: E.conductor()
    4287         287296
    4288         sage: isogenies_sporadic_Q(E,67)
    4289         [Isogeny of degree 67 from Elliptic Curve defined by y^2 = x^3 - 29480*x - 1948226 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 132335720*x + 585954296438 over Rational Field]
    4290 
    4291         sage: E = EllipticCurve([-34790720, -78984748304])
    4292         sage: E.conductor()
    4293         425104
    4294         sage: isogenies_sporadic_Q(E,163)
    4295         [Isogeny of degree 163 from Elliptic Curve defined by y^2 = x^3 - 34790720*x - 78984748304 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 924354639680*x + 342062961763303088 over Rational Field]
    4296     """
    4297     if E.base_ring() != QQ:
    4298         raise ValueError, "The elliptic curve must be defined over QQ."
    4299     j = E.j_invariant()
    4300     j = QQ(j)
    4301     if l != None:
    4302         if not l.is_prime():
    4303             raise ValueError("%s is not prime."%l)
    4304         if not isog_table.has_key((l,j)):
    4305             return []
    4306         Ew = E.short_weierstrass_model()
    4307         E_to_Ew = E.isomorphism_to(Ew)
    4308         c4, c6 = Ew.c_invariants()
    4309         (a4,a6), f = isog_table[(l,j)]
    4310         d = (c6*a4)/(18*c4*a6) # twisting factor
    4311         R = PolynomialRing(E.base_field(),'X')
    4312         n = len(f)
    4313         ker = R([d**(n-i-1) * f[i] for i in range(n)])
    4314         isog = Ew.isogeny(kernel=ker, degree=l, model="minimal", check=False)
    4315         isog.set_pre_isomorphism(E_to_Ew)
    4316         return [isog]
    4317     if l is None:
    4318         if isog_table.has_key((11,j)):
    4319             return isogenies_sporadic_Q(E, Integer(11))
    4320         if isog_table.has_key((17,j)):
    4321             return isogenies_sporadic_Q(E, Integer(17))
    4322         if isog_table.has_key((19,j)):
    4323             return isogenies_sporadic_Q(E, Integer(19))
    4324         if isog_table.has_key((37,j)):
    4325             return isogenies_sporadic_Q(E, Integer(37))
    4326         if isog_table.has_key((43,j)):
    4327             return isogenies_sporadic_Q(E, Integer(43))
    4328         if isog_table.has_key((67,j)):
    4329             return isogenies_sporadic_Q(E, Integer(67))
    4330         if isog_table.has_key((163,j)):
    4331             return isogenies_sporadic_Q(E, Integer(163))
    4332         else:
    4333             return []
    4334 
    4335 def isogenies_2(E):
    4336     """
    4337     Returns a list of all 2-isogenies with domain ``E``.
    4338 
    4339     INPUT:
    4340 
    4341     - ``E`` -- an elliptic curve.
    4342 
    4343     OUTPUT:
    4344 
    4345     (list) 2-isogenies with domain ``E``.  In general these are
    4346     normalised, but over `\QQ` the codomain is a minimal model.
    4347 
    4348     EXAMPLES::
    4349 
    4350         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_2   
    4351         sage: E = EllipticCurve('14a1'); E
    4352         Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field
    4353         sage: [phi.codomain().ainvs() for phi in isogenies_2(E)]
    4354         [(1, 0, 1, -36, -70)]
    4355 
    4356         sage: E = EllipticCurve([1,2,3,4,5]); E
    4357         Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field
    4358         sage: [phi.codomain().ainvs() for phi in isogenies_2(E)]
    4359         []
    4360         sage: E = EllipticCurve(QQbar, [9,8]); E 
    4361         Elliptic Curve defined by y^2 = x^3 + 9*x + 8 over Algebraic Field
    4362         sage: isogenies_2(E) # not implemented
    4363     """
    4364     f2 = E.division_polynomial(2)
    4365     x2 = f2.roots(multiplicities=False)
    4366     x2.sort()
    4367     x = f2.parent().gen()
    4368     ff = [x-x2i for x2i in x2]
    4369     model = "minimal" if E.base_field() is QQ else None
    4370     isogs = [E.isogeny(f, model=model) for f in ff]
    4371     return isogs
    4372    
    4373 def isogenies_3(E):
    4374     """
    4375     Returns a list of all 3-isogenies with domain ``E``.
    4376 
    4377     INPUT:
    4378 
    4379     - ``E`` -- an elliptic curve.
    4380 
    4381     OUTPUT:
    4382 
    4383     (list) 3-isogenies with domain ``E``.  In general these are
    4384     normalised, but over `\QQ` the codomain is a minimal model.
    4385 
    4386     EXAMPLES::
    4387 
    4388         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_3
    4389         sage: E = EllipticCurve(GF(17), [1,1])
    4390         sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
    4391         [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1)]
    4392 
    4393         sage: E = EllipticCurve(GF(17^2,'a'), [1,1])
    4394         sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
    4395         [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1), (0, 0, 0, 5*a + 1, a + 13), (0, 0, 0, 12*a + 6, 16*a + 14)]
    4396 
    4397         sage: E = EllipticCurve('19a1')   
    4398         sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
    4399         [(0, 1, 1, 1, 0), (0, 1, 1, -769, -8470)]
    4400 
    4401         sage: E = EllipticCurve([1,1])
    4402         sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
    4403         []
    4404     """
    4405     f3 = E.division_polynomial(3)
    4406     x3 = f3.roots(multiplicities=False)
    4407     x3.sort()
    4408     x = f3.parent().gen()
    4409     ff = [x-x3i for x3i in x3]
    4410     model = "minimal" if E.base_field() is QQ else None
    4411     isogs = [E.isogeny(f, model=model) for f in ff]
    4412     return isogs
    4413 
    4414 # 6 special cases: `l` = 5, 7, 13 and `j` = 0, 1728.
    4415 
    4416 def isogenies_5_0(E):
    4417     """
    4418     Returns a list of all the 5-isogenies  with domain ``E`` when the
    4419     j-invariant is 0.
    4420 
    4421     OUTPUT:
    4422 
    4423     (list) 5-isogenies with codomain E.  In general these are
    4424     normalised, but over `\QQ` the codomain is a minimal model.
    4425 
    4426     .. note::
    4427 
    4428        This implementation requires that the characteristic is not 2,
    4429        3 or 5.
    4430 
    4431     .. note::
    4432 
    4433        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(5)``.
    4434 
    4435     EXAMPLES::
    4436 
    4437         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_5_0
    4438         sage: E = EllipticCurve([0,12])
    4439         sage: isogenies_5_0(E)                             
    4440         []
    4441 
    4442         sage: E = EllipticCurve(GF(13^2,'a'),[0,-3])
    4443         sage: isogenies_5_0(E)
    4444         [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (4*a+6)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (12*a+5)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (10*a+2)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (3*a+12)*x + (11*a+12) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (a+4)*x + (11*a+12) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (9*a+10)*x + (11*a+12) over Finite Field in a of size 13^2]
    4445 
    4446         sage: K.<a> = NumberField(x**6-320*x**3-320)
    4447         sage: E = EllipticCurve(K,[0,0,1,0,0])
    4448         sage: isogenies_5_0(E)                     
    4449         [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 = x^3 + (a^5-400*a^2)*x + (280*a^3-3120) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320,
    4450         Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 = x^3 + (23/2*a^5-3700*a^2)*x + (-280*a^3+86480) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320]
    4451 
    4452     """
    4453     F = E.base_field()
    4454     if E.j_invariant() != 0:
    4455         raise ValueError, "j-invariant must be 0."
    4456     if F.characteristic() in [2,3,5]:
    4457         raise NotImplementedError, "Not implemented in characteristic 2, 3 or 5."
    4458     if not F(5).is_square():
    4459         return []
    4460     Ew = E.short_weierstrass_model()
    4461     a = Ew.a6()
    4462     x = polygen(F)
    4463     betas = (x**6-160*a*x**3-80*a**2).roots(multiplicities=False)
    4464     betas.sort()
    4465     if len(betas)==0:
    4466         return []
    4467     gammas = [(beta**2 *(beta**3-140*a))/(120*a) for beta in betas]
    4468     model = "minimal" if F is QQ else None
    4469     isogs = [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
    4470     iso = E.isomorphism_to(Ew)
    4471     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4472     return isogs
    4473 
    4474 def isogenies_5_1728(E):
    4475     """
    4476     Returns a list of 5-isogenies with domain ``E`` when the j-invariant is
    4477     1728.
    4478 
    4479     OUTPUT:
    4480 
    4481     (list) 5-isogenies with codomain E.  In general these are
    4482     normalised; but if `-1` is a square then there are two
    4483     endomorphisms of degree `5`, for which the codomain is the same as
    4484     the domain curve; and over `\QQ`, the codomain is a minimal model.
    4485 
    4486     .. note::
    4487 
    4488        This implementation requires that the characteristic is not 2,
    4489        3 or 5.
    4490 
    4491     .. note::
    4492 
    4493        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(5)``.
    4494 
    4495     EXAMPLES::
    4496        
    4497         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_5_1728
    4498         sage: E = EllipticCurve([7,0])   
    4499         sage: isogenies_5_1728(E)
    4500         []
    4501 
    4502         sage: E = EllipticCurve(GF(13),[11,0])
    4503         sage: isogenies_5_1728(E)       
    4504         [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13,
    4505         Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13]
    4506 
    4507     An example of endomorphisms of degree 5::
    4508 
    4509         sage: K.<i> = QuadraticField(-1)                   
    4510         sage: E = EllipticCurve(K,[0,0,0,1,0])
    4511         sage: isogenies_5_1728(E)             
    4512         [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1,
    4513         Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1]
    4514         sage: _[0].rational_maps()
    4515         (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)),
    4516          ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y + (141/125*i + 162/125)*x^2*y + (3/25*i - 4/25)*y)/(x^6 + (-6/5*i + 3/5)*x^4 + (-12/25*i - 9/25)*x^2 + (2/125*i - 11/125)))
    4517 
    4518     An example of 5-isogenies over a number field::
    4519 
    4520         sage: K.<a> = NumberField(x**4+20*x**2-80)
    4521         sage: K(5).is_square() #necessary but not sufficient!                   
    4522         True
    4523         sage: E = EllipticCurve(K,[0,0,0,1,0])   
    4524         sage: isogenies_5_1728(E)                 
    4525         [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 to Elliptic Curve defined by y^2 = x^3 + (-20*a^2-39)*x + (35*a^3+112*a) over Number Field in a with defining polynomial x^4 + 20*x^2 - 80,
    4526         Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 to Elliptic Curve defined by y^2 = x^3 + (-20*a^2-39)*x + (-35*a^3-112*a) over Number Field in a with defining polynomial x^4 + 20*x^2 - 80]
    4527    
    4528     """
    4529     F = E.base_field()
    4530     if E.j_invariant() != 1728:
    4531         raise ValueError, "j-invariant must be 1728."
    4532     if F.characteristic() in [2,3,5]:
    4533         raise NotImplementedError, "Not implemented in characteristic 2, 3 or 5."
    4534     model = "minimal" if F is QQ else None
    4535     # quick test for a negative answer (from Fricke module)
    4536     square5 = F(5).is_square()
    4537     square1 = F(-1).is_square()
    4538     if not square5 and not square1:
    4539         return []
    4540     Ew = E.short_weierstrass_model()
    4541     iso = E.isomorphism_to(Ew)
    4542     a = Ew.a4()
    4543     x = polygen(F)
    4544     isogs = []
    4545     # 2 cases
    4546     # Type 1: if -1 is a square we have 2 endomorphisms
    4547     if square1:
    4548         i = F(-1).sqrt()
    4549         isogs = [Ew.isogeny(f) for f in [x**2+a/(1+2*i), x**2+a/(1-2*i)]]
    4550         [isog.set_post_isomorphism(isog.codomain().isomorphism_to(E)) for isog in isogs]
    4551     # Type 2: if 5 is a square we have up to 4 (non-endomorphism) isogenies
    4552     if square5:
    4553         betas = (x**4+20*a*x**2-80*a**2).roots(multiplicities=False)
    4554         betas.sort()
    4555         gammas = [a*(beta**2-2)/6 for beta in betas]
    4556         isogs += [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
    4557     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4558     return isogs
    4559 
    4560 def isogenies_7_0(E):
    4561     """
    4562     Returns list of all 7-isogenies from E when the j-invariant is 0.
    4563 
    4564     OUTPUT:
    4565 
    4566     (list) 7-isogenies with codomain E.  In general these are
    4567     normalised; but if `-3` is a square then there are two
    4568     endomorphisms of degree `7`, for which the codomain is the same as
    4569     the domain; and over `\QQ`, the codomain is a minimal model.
    4570 
    4571     .. note::
    4572 
    4573        This implementation requires that the characteristic is not 2,
    4574        3 or 7.
    4575 
    4576     .. note::
    4577 
    4578        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(7)``.
    4579 
    4580     EXAMPLES:
    4581 
    4582     First some examples of endomorphisms::
    4583 
    4584         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_7_0   
    4585         sage: K.<r> = QuadraticField(-3)
    4586         sage: E = EllipticCurve(K, [0,1]) 
    4587         sage: isogenies_7_0(E)
    4588         [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3,
    4589         Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3]
    4590 
    4591         sage: E = EllipticCurve(GF(13^2,'a'),[0,-3])
    4592         sage: isogenies_7_0(E)       
    4593         [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2, Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2]
    4594 
    4595     Now some examples of 7-isogenies which are not endomorphisms::
    4596 
    4597         sage: K = GF(101)               
    4598         sage: E = EllipticCurve(K, [0,1])
    4599         sage: isogenies_7_0(E)           
    4600         [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 55*x + 100 over Finite Field of size 101, Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 83*x + 26 over Finite Field of size 101]
    4601 
    4602     Examples over a number field::
    4603 
    4604         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_7_0
    4605         sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r'))
    4606         sage: isogenies_7_0(E)
    4607         [Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3,
    4608         Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3]
    4609 
    4610         sage: K.<a> = NumberField(x^6 + 1512*x^3 - 21168)
    4611         sage: E = EllipticCurve(K, [0,1])
    4612         sage: isogs = isogenies_7_0(E)
    4613         sage: [phi.codomain().a_invariants() for phi in isogs]
    4614         [(0, 0, 0, -5/294*a^5 - 300/7*a^2, -55/2*a^3 - 1133),
    4615         (0, 0, 0, -295/1176*a^5 - 5385/14*a^2, 55/2*a^3 + 40447)]
    4616         sage: [phi.codomain().j_invariant() for phi in isogs]
    4617         [158428486656000/7*a^3 - 313976217600000,
    4618         -158428486656000/7*a^3 - 34534529335296000]
    4619     """
    4620     if E.j_invariant()!=0:
    4621         raise ValueError, "j-invariant must be 0."
    4622     F = E.base_field()
    4623     if F.characteristic() in [2,3,7]:
    4624         raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 7."
    4625     x = polygen(F)
    4626     Ew = E.short_weierstrass_model()
    4627     iso = E.isomorphism_to(Ew)
    4628     a = Ew.a6()
    4629     model = "minimal" if F is QQ else None
    4630 
    4631     # there will be 2 endomorphisms if -3 is a square:
    4632 
    4633     ts = (x**2+3).roots(multiplicities=False)
    4634     ts.sort()
    4635     kers = [7*x-(2+6*t) for t in ts]
    4636     kers = [k(x**3/a).monic() for k in kers]
    4637     isogs = [Ew.isogeny(k,model=model) for k in kers]
    4638     if len(isogs)>0:
    4639         [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
    4640 
    4641     # we may have up to 6 other isogenies:
    4642     ts = (x**2-21).roots(multiplicities=False)
    4643     for t0 in ts:
    4644         s3 = a/(28+6*t0)
    4645         ss = (x**3-s3).roots(multiplicities=False)
    4646         ss.sort()
    4647         ker = x**3 - 2*t0*x**2 - 4*t0*x + 4*t0 + 28
    4648         kers = [ker(x/s).monic() for s in ss]
    4649         isogs += [Ew.isogeny(k, model=model) for k in kers]
    4650    
    4651     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4652     return isogs
    4653 
    4654 def isogenies_7_1728(E):
    4655     """
    4656     Returns list of all 7-isogenies from E when the j-invariant is 1728.
    4657 
    4658     OUTPUT:
    4659 
    4660     (list) 7-isogenies with codomain E.  In general these are
    4661     normalised; but over `\QQ` the codomain is a minimal model.
    4662 
    4663     .. note::
    4664 
    4665        This implementation requires that the characteristic is not 2,
    4666        3, or 7.
    4667 
    4668     .. note::
    4669 
    4670        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(7)``.
    4671 
    4672     EXAMPLES::
    4673 
    4674         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_7_1728                                                                           
    4675         sage: E = EllipticCurve(GF(47), [1, 0])
    4676         sage: isogenies_7_1728(E)             
    4677         [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 26 over Finite Field of size 47,
    4678         Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 21 over Finite Field of size 47]
    4679 
    4680     An example in characteristic 53 (for which an earlier implementation did not work)::   
    4681 
    4682         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_7_1728
    4683         sage: E = EllipticCurve(GF(53), [1, 0])
    4684         sage: isogenies_7_1728(E)
    4685         []
    4686         sage: E = EllipticCurve(GF(53^2,'a'), [1, 0])
    4687         sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)]
    4688         [(0, 0, 0, 36, 19*a + 15), (0, 0, 0, 36, 34*a + 38), (0, 0, 0, 33, 39*a + 28), (0, 0, 0, 33, 14*a + 25), (0, 0, 0, 19, 45*a + 16), (0, 0, 0, 19, 8*a + 37), (0, 0, 0, 3, 45*a + 16), (0, 0, 0, 3, 8*a + 37)]
    4689 
    4690     ::   
    4691 
    4692         sage: K.<a> = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567)
    4693         sage: E = EllipticCurve(K, [1, 0])                               
    4694         sage: isogs = isogenies_7_1728(E)
    4695         sage: [phi.codomain().a_invariants() for phi in isogs]
    4696         [(0,
    4697         0,
    4698         0,
    4699         35/636*a^6 + 55/12*a^4 - 79135/636*a^2 + 1127/212,
    4700         155/636*a^7 + 245/12*a^5 - 313355/636*a^3 - 3577/636*a),
    4701         (0,
    4702         0,
    4703         0,
    4704         35/636*a^6 + 55/12*a^4 - 79135/636*a^2 + 1127/212,
    4705         -155/636*a^7 - 245/12*a^5 + 313355/636*a^3 + 3577/636*a)]
    4706         sage: [phi.codomain().j_invariant() for phi in isogs]
    4707         [-526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53,
    4708         -526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53]
    4709         sage: E1 = isogs[0].codomain()
    4710         sage: E2 = isogs[1].codomain()
    4711         sage: E1.is_isomorphic(E2)
    4712         False
    4713         sage: E1.is_quadratic_twist(E2)
    4714         -1
    4715     """
    4716     if E.j_invariant()!=1728:
    4717         raise ValueError, "j_invariant must be 1728 (in base field)."
    4718     F = E.base_field()
    4719     if F.characteristic() in [2,3,7]:
    4720         raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 7."
    4721     Ew = E.short_weierstrass_model()
    4722     iso = E.isomorphism_to(Ew)
    4723     a = Ew.a4()
    4724 
    4725     ts = (Fricke_module(7)-1728).numerator().roots(F,multiplicities=False)
    4726     if len(ts)==0:
    4727         return []
    4728     ts.sort()
    4729     isogs = []
    4730     model = "minimal" if F is QQ else None
    4731     x = polygen(F)
    4732     for t0 in ts:
    4733         s2 = a/t0
    4734         ss = (x**2-s2).roots(multiplicities=False)
    4735         ss.sort()
    4736         ker = 9*x**3 + (-3*t0**3 - 36*t0**2 - 123*t0)*x**2 + (-8*t0**3 - 101*t0**2 - 346*t0 + 35)*x - 7*t0**3 - 88*t0**2 - 296*t0 + 28
    4737 
    4738         kers = [ker(x/s) for s in ss]
    4739         isogs += [Ew.isogeny(k.monic(), model=model) for k in kers]
    4740     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4741     return isogs
    4742 
    4743 def isogenies_13_0(E):
    4744     """
    4745     Returns list of all 13-isogenies from E when the j-invariant is 0.
    4746 
    4747     OUTPUT:
    4748 
    4749     (list) 13-isogenies with codomain E.  In general these are
    4750     normalised; but if `-3` is a square then there are two
    4751     endomorphisms of degree `13`, for which the codomain is the same
    4752     as the domain.
    4753 
    4754     .. note::
    4755 
    4756        This implementation requires that the characteristic is not 2,
    4757        3 or 13.
    4758 
    4759     .. note::
    4760 
    4761        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(13)``.
    4762 
    4763     EXAMPLES::
    4764 
    4765         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_13_0 
    4766 
    4767     Endomorphisms of degree 13 will exist when -3 is a square::   
    4768 
    4769         sage: K.<r> = QuadraticField(-3)
    4770         sage: E = EllipticCurve(K, [0, r]); E
    4771         Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3
    4772         sage: isogenies_13_0(E)
    4773         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3,
    4774         Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3]
    4775         sage: isogenies_13_0(E)[0].rational_maps()
    4776         (((7/338*r + 23/338)*x^13 + (-164/13*r - 420/13)*x^10 + (720/13*r + 3168/13)*x^7 + (3840/13*r - 576/13)*x^4 + (4608/13*r + 2304/13)*x)/(x^12 + (4*r + 36)*x^9 + (1080/13*r + 3816/13)*x^6 + (2112/13*r - 5184/13)*x^3 + (-17280/169*r - 1152/169)), ((18/2197*r + 35/2197)*x^18*y + (23142/2197*r + 35478/2197)*x^15*y + (-1127520/2197*r - 1559664/2197)*x^12*y + (-87744/2197*r + 5992704/2197)*x^9*y + (-6625152/2197*r - 9085824/2197)*x^6*y + (-28919808/2197*r - 2239488/2197)*x^3*y + (-1990656/2197*r - 3870720/2197)*y)/(x^18 + (6*r + 54)*x^15 + (3024/13*r + 11808/13)*x^12 + (31296/13*r + 51840/13)*x^9 + (487296/169*r - 2070144/169)*x^6 + (-940032/169*r + 248832/169)*x^3 + (1990656/2197*r + 3870720/2197)))
    4777 
    4778     An example of endomorphisms over a finite field::
    4779    
    4780         sage: K = GF(19^2,'a')
    4781         sage: E = EllipticCurve(j=K(0)); E
    4782         Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2
    4783         sage: isogenies_13_0(E)                   
    4784         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2,
    4785         Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2]
    4786         sage: isogenies_13_0(E)[0].rational_maps()
    4787         ((6*x^13 - 6*x^10 - 3*x^7 + 6*x^4 + x)/(x^12 - 5*x^9 - 9*x^6 - 7*x^3 + 5), (-8*x^18*y - 9*x^15*y + 9*x^12*y - 5*x^9*y + 5*x^6*y - 7*x^3*y + 7*y)/(x^18 + 2*x^15 + 3*x^12 - x^9 + 8*x^6 - 9*x^3 + 7))
    4788 
    4789     A previous implementation did not work in some characteristics::   
    4790 
    4791         sage: K = GF(29)
    4792         sage: E = EllipticCurve(j=K(0))
    4793         sage: isogenies_13_0(E)
    4794         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 26*x + 12 over Finite Field of size 29, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 16*x + 28 over Finite Field of size 29]
    4795 
    4796     ::
    4797 
    4798         sage: K = GF(101)                                         
    4799         sage: E = EllipticCurve(j=K(0)); E.ainvs()                 
    4800         (0, 0, 0, 0, 1)
    4801         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
    4802         [(0, 0, 0, 64, 36), (0, 0, 0, 42, 66)]
    4803 
    4804     ::
    4805 
    4806         sage: x = polygen(QQ)
    4807         sage: f = x^12 + 78624*x^9 - 130308048*x^6 + 2270840832*x^3 - 54500179968
    4808         sage: K.<a> = NumberField(f)     
    4809         sage: E = EllipticCurve(j=K(0)); E.ainvs()
    4810         (0, 0, 0, 0, 1)
    4811         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
    4812         [(0, 0, 0, -739946459/23857162861049856*a^11 - 2591641747/1062017577504*a^8 + 16583647773233/4248070310016*a^5 - 14310911337/378211388*a^2, 26146225/4248070310016*a^9 + 7327668845/14750244132*a^6 + 174618431365/756422776*a^3 - 378332499709/94552847), (0, 0, 0, 3501275/5964290715262464*a^11 + 24721025/531008788752*a^8 - 47974903745/1062017577504*a^5 - 6773483100/94552847*a^2, 6699581/4248070310016*a^9 + 1826193509/14750244132*a^6 - 182763866047/756422776*a^3 - 321460597/94552847)]
    4813     """
    4814     if E.j_invariant()!=0:
    4815         raise ValueError, "j-invariant must be 0."
    4816     F = E.base_field()
    4817     if F.characteristic() in [2,3,13]:
    4818         raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 13."
    4819     Ew = E.short_weierstrass_model()
    4820     iso = E.isomorphism_to(Ew)
    4821     a = Ew.a6()
    4822     model = "minimal" if F is QQ else None
    4823     x = polygen(F)
    4824 
    4825     # there will be 2 endomorphisms if -3 is a square:
    4826     ts = (x**2+3).roots(multiplicities=False)
    4827     ts.sort()
    4828     kers = [13*x**2 + (78*t + 26)*x + 24*t + 40 for t in ts]
    4829     kers = [k(x**3/a).monic() for k in kers]
    4830     isogs = [Ew.isogeny(k,model=model) for k in kers]
    4831     if len(isogs)>0:
    4832         [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
    4833  
    4834     # we may have up to 12 other isogenies:
    4835     ts = (x**4 + 7*x**3 + 20*x**2 + 19*x + 1).roots(multiplicities=False)
    4836     ts.sort()
    4837     for t0 in ts:
    4838         s3 = a / (6*t0**3 + 32*t0**2 + 68*t0 + 4)
    4839         ss = (x**3-s3).roots(multiplicities=False)
    4840         ss.sort()
    4841         ker = (x**6 + (20*t0**3 + 106*t0**2 + 218*t0 + 4)*x**5
    4842             + (-826*t0**3 - 4424*t0**2 - 9244*t0 - 494)*x**4
    4843             + (13514*t0**3 + 72416*t0**2 + 151416*t0 + 8238)*x**3
    4844             + (-101948*t0**3 - 546304*t0**2 - 1142288*t0 - 62116)*x**2
    4845             + (354472*t0**3 + 1899488*t0**2 + 3971680*t0 + 215960)*x
    4846             - 459424*t0**3 - 2461888*t0**2 - 5147648*t0 - 279904)
    4847         kers = [ker(x/s).monic() for s in ss]
    4848         isogs += [Ew.isogeny(k, model=model) for k in kers]
    4849    
    4850     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4851 
    4852     return isogs
    4853 
    4854 def isogenies_13_1728(E):
    4855     """
    4856     Returns list of all 13-isogenies from E when the j-invariant is 1728.
    4857 
    4858     OUTPUT:
    4859 
    4860     (list) 13-isogenies with codomain E.  In general these are
    4861     normalised; but if `-1` is a square then there are two
    4862     endomorphisms of degree `13`, for which the codomain is the same
    4863     as the domain; and over `\QQ`, the codomain is a minimal model.
    4864 
    4865     .. note::
    4866 
    4867        This implementation requires that the characteristic is not
    4868        2, 3 or 13.
    4869 
    4870     .. note::
    4871 
    4872        This function would normally be invoked indirectly via ``E.isogenies_prime_degree(13)``.
    4873 
    4874     EXAMPLES::
    4875 
    4876         sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogenies_13_1728
    4877 
    4878         sage: K.<i> = QuadraticField(-1)
    4879         sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs()
    4880         (0, 0, 0, i, 0)
    4881         sage: isogenies_13_1728(E)
    4882         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1,
    4883         Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1]
    4884 
    4885     ::
    4886 
    4887         sage: K = GF(83)
    4888         sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs()
    4889         (0, 0, 0, 5, 0)
    4890         sage: isogenies_13_1728(E)                       
    4891         []
    4892         sage: K = GF(89)                                 
    4893         sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs()
    4894         (0, 0, 0, 5, 0)
    4895         sage: isogenies_13_1728(E)                       
    4896         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89,
    4897         Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89]
    4898 
    4899     ::
    4900 
    4901         sage: K = GF(23)                                     
    4902         sage: E = EllipticCurve(K, [1,0])                     
    4903         sage: isogenies_13_1728(E)                           
    4904         [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 16 over Finite Field of size 23, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 7 over Finite Field of size 23]
    4905 
    4906     ::
    4907 
    4908         sage: x = polygen(QQ)
    4909         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
    4910         sage: K.<a> = NumberField(f)
    4911         sage: E = EllipticCurve(K, [1,0])
    4912         sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
    4913         [(0,
    4914         0,
    4915         0,
    4916         11090413835/20943727039698624*a^10 + 32280103535965/55849938772529664*a^8 - 355655987835845/1551387188125824*a^6 + 19216954517530195/5235931759924656*a^4 - 1079766118721735/5936430566808*a^2 + 156413528482727/8080141604822,
    4917         214217013065/82065216155553792*a^11 + 1217882637605/427423000810176*a^9 - 214645003230565/189965778137856*a^7 + 22973355421236025/1282269002430528*a^5 - 2059145797340695/2544184528632*a^3 - 23198483147321/989405094468*a),
    4918         (0,
    4919         0,
    4920         0,
    4921         11090413835/20943727039698624*a^10 + 32280103535965/55849938772529664*a^8 - 355655987835845/1551387188125824*a^6 + 19216954517530195/5235931759924656*a^4 - 1079766118721735/5936430566808*a^2 + 156413528482727/8080141604822,
    4922         -214217013065/82065216155553792*a^11 - 1217882637605/427423000810176*a^9 + 214645003230565/189965778137856*a^7 - 22973355421236025/1282269002430528*a^5 + 2059145797340695/2544184528632*a^3 + 23198483147321/989405094468*a)]
    4923    
    4924     """
    4925     if E.j_invariant()!=1728:
    4926         raise ValueError, "j-invariant must be 1728."
    4927     F = E.base_field()
    4928     if F.characteristic() in [2, 3, 7, 13, 167, 233, 271, 1117]:
    4929         raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 13."
    4930     Ew = E.short_weierstrass_model()
    4931     iso = E.isomorphism_to(Ew)
    4932     a = Ew.a4()
    4933     model = "minimal" if F is QQ else None
    4934     x = polygen(F)
    4935 
    4936     # we will have two endomorphisms if -1 is a square:
    4937     ts = (x**2+1).roots(multiplicities=False)
    4938     ts.sort()
    4939     kers = [13*x**3 + (-26*i - 13)*x**2 + (-52*i - 13)*x - 2*i - 3 for i in ts]
    4940     kers = [k(x**2/a).monic() for k in kers]
    4941     isogs = [Ew.isogeny(k,model=model) for k in kers]
    4942     if len(isogs)>0:
    4943         [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
    4944 
    4945     # we may have up to 12 other isogenies:
    4946 
    4947     ts = (x**6 + 10*x**5 + 46*x**4 + 108*x**3 + 122*x**2 + 38*x - 1).roots(multiplicities=False)
    4948     ts.sort()
    4949     for t0 in ts:
    4950         s2 = a/(66*t0**5 + 630*t0**4 + 2750*t0**3 + 5882*t0**2 + 5414*t0 + 162)
    4951         ss = (x**2-s2).roots(multiplicities=False)
    4952         ss.sort()
    4953         ker = (x**6 + (-66*t0**5 - 630*t0**4 - 2750*t0**3 - 5882*t0**2
    4954               - 5414*t0 - 162)*x**5 + (-21722*t0**5 - 205718*t0**4 -
    4955               890146*t0**3 - 1873338*t0**2 - 1652478*t0 + 61610)*x**4
    4956               + (-3391376*t0**5 - 32162416*t0**4 - 139397232*t0**3 -
    4957               294310576*t0**2 - 261885968*t0 + 6105552)*x**3 +
    4958               (-241695080*t0**5 - 2291695976*t0**4 - 9930313256*t0**3
    4959               - 20956609720*t0**2 - 18625380856*t0 + 469971320)*x**2 +
    4960               (-8085170432*t0**5 - 76663232384*t0**4 -
    4961               332202985024*t0**3 - 701103233152*t0**2 -
    4962               623190845440*t0 + 15598973056)*x - 101980510208*t0**5 -
    4963               966973468160*t0**4 - 4190156868352*t0**3 -
    4964               8843158270336*t0**2 - 7860368751232*t0 + 196854655936)
    4965        
    4966         kers = [ker(x/s).monic() for s in ss]
    4967         isogs += [Ew.isogeny(k, model=model) for k in kers]
    4968 
    4969     [isog.set_pre_isomorphism(iso) for isog in isogs]
    4970    
    4971     return isogs
    4972 
    49733880# Utility function for manipulating isogeny degree matrices
    49743881
    49753882def fill_isogeny_matrix(M):
  • sage/schemes/elliptic_curves/ell_field.py

    diff --git a/sage/schemes/elliptic_curves/ell_field.py b/sage/schemes/elliptic_curves/ell_field.py
    a b  
    950950        if F == rings.QQbar:
    951951            raise NotImplementedError, "This code could be implemented for QQbar, but has not been yet."
    952952
    953         from ell_curve_isogeny import isogenies_prime_degree_genus_0
     953        from isogeny_genus_0 import isogenies_prime_degree_genus_0
    954954        if l is None:
    955955            l = [2, 3, 5, 7, 13]
    956956        if l in [2, 3, 5, 7, 13]:
  • sage/schemes/elliptic_curves/ell_rational_field.py

    diff --git a/sage/schemes/elliptic_curves/ell_rational_field.py b/sage/schemes/elliptic_curves/ell_rational_field.py
    a b  
    42044204            ValueError: 4 is not prime.
    42054205
    42064206        """
    4207         from ell_curve_isogeny import isogenies_prime_degree_genus_0, isogenies_sporadic_Q
     4207        from isogeny_genus_0 import isogenies_prime_degree_genus_0, isogenies_sporadic_Q
    42084208       
    42094209        if l in [2, 3, 5, 7, 13]:
    42104210            return isogenies_prime_degree_genus_0(self, l)
  • new file sage/schemes/elliptic_curves/isogeny_genus_0.py

    diff --git a/sage/schemes/elliptic_curves/isogeny_genus_0.py b/sage/schemes/elliptic_curves/isogeny_genus_0.py
    new file mode 100644
    - +  
     1r"""
     2Isogenies
     3
     4We compute isogenies of degree l = 2, 3, 5, 7, or 13, where the modular curve X_0(l) has genus 0.
     5
     6
     7AUTHORS:
     8
     9- YOUR NAME (2012-10-18): initial version
     10
     11- person (date in ISO year-month-day format): short desc
     12
     13...
     14
     15- person (date in ISO year-month-day format): short desc
     16
     17...
     18
     19Lots and lots of examples.
     20"""
     21
     22#*****************************************************************************
     23#       Copyright (C) 2012 YOUR NAME <your email>
     24#
     25#  Distributed under the terms of the GNU General Public License (GPL)
     26#  as published by the Free Software Foundation; either version 2 of
     27#  the License, or (at your option) any later version.
     28#                  http://www.gnu.org/licenses/
     29#*****************************************************************************
     30
     31from copy import deepcopy, copy
     32
     33from sage.categories import homset
     34
     35from sage.categories.morphism import Morphism
     36
     37from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
     38from sage.rings.polynomial.polynomial_ring import polygen
     39from sage.rings.all import Integer, ZZ
     40from sage.rings.laurent_series_ring import LaurentSeriesRing
     41from sage.rings.polynomial.all import is_Polynomial
     42from sage.schemes.elliptic_curves.all import EllipticCurve
     43from sage.schemes.elliptic_curves.all import is_EllipticCurve
     44
     45from sage.rings.number_field.number_field_base import is_NumberField
     46
     47from sage.rings.rational_field import is_RationalField, QQ
     48
     49from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
     50
     51from sage.sets.set import Set
     52
     53from sage.misc.cachefunc import cached_function
     54
     55##########################################################################
     56# The following section is all about computing l-isogenies, where l is
     57# a prime.  The genus 0 cases `l` = 2, 3, 5, 7 and 13 are
     58# implemented over any field of characteristic not 2, 3 or `l`; over
     59# `\QQ` the "sporadic" cases `l` = 11, 17, 19, 37, 43, 67 or 163 with
     60# only finitely many `j`-invariants each. are also implemented.
     61##########################################################################
     62
     63@cached_function
     64def Fricke_polynomial(l):
     65    r"""
     66    Fricke polynomial for ``l`` =2,3,5,7,13.
     67
     68    For these primes (and these only) the modular curve `X_0(l)` has
     69    genus zero, and its field is generated by a single modular
     70    function called the Fricke module (or Hauptmodul), `t`.  There is
     71    a classical choice of such a generator `t` in each case, and the
     72    `j`-function is a rational function of `t` of degree `l+1` of the
     73    form `P(t)/t` where `P` is a polynomial of degree `l+1`.  Up to
     74    scaling, `t` is determined by the condition that the ramification
     75    points above `j=\infty` are `t=0` (with ramification degree `1`)
     76    and `t=\infty` (with degree `l`).  The ramification above `j=0`
     77    and `j=1728` may be seen in the factorizations of `j(t)` and
     78    `k(t)` where `k=j-1728`.
     79
     80    OUTPUT:
     81
     82    The polynomial `P(t)` as an element of `\ZZ[t]`.
     83
     84    TESTS::
     85
     86        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import Fricke_polynomial
     87        sage: Fricke_polynomial(2)
     88        t^3 + 48*t^2 + 768*t + 4096
     89        sage: Fricke_polynomial(3)
     90        t^4 + 36*t^3 + 270*t^2 + 756*t + 729
     91        sage: Fricke_polynomial(5)
     92        t^6 + 30*t^5 + 315*t^4 + 1300*t^3 + 1575*t^2 + 750*t + 125
     93        sage: Fricke_polynomial(7)
     94        t^8 + 28*t^7 + 322*t^6 + 1904*t^5 + 5915*t^4 + 8624*t^3 + 4018*t^2 + 748*t + 49
     95        sage: Fricke_polynomial(13)
     96        t^14 + 26*t^13 + 325*t^12 + 2548*t^11 + 13832*t^10 + 54340*t^9 + 157118*t^8 + 333580*t^7 + 509366*t^6 + 534820*t^5 + 354536*t^4 + 124852*t^3 + 15145*t^2 + 746*t + 13
     97    """
     98    Zt = PolynomialRing(ZZ,'t')
     99    t = Zt.gen()
     100    if l==2: return (t+16)**3
     101    elif l==3: return (t+3)**3*(t+27)
     102    elif l==5: return (t**2+10*t+5)**3
     103    elif l==7: return (t**2+5*t+1)**3 * (t**2+13*t+49)
     104    elif l==13: return (t**2+5*t+13)*(t**4+7*t**3+20*t**2+19*t+1)**3
     105    else:
     106        raise ValueError, "The only genus zero primes are 2, 3, 5, 7 or 13."
     107
     108@cached_function
     109def Fricke_module(l):
     110    r"""
     111    Fricke module for ``l`` =2,3,5,7,13.
     112
     113    For these primes (and these only) the modular curve `X_0(l)` has
     114    genus zero, and its field is generated by a single modular
     115    function called the Fricke module (or Hauptmodul), `t`.  There is
     116    a classical choice of such a generator `t` in each case, and the
     117    `j`-function is a rational function of `t` of degree `l+1` of the
     118    form `P(t)/t` where `P` is a polynomial of degree `l+1`.  Up to
     119    scaling, `t` is determined by the condition that the ramification
     120    points above `j=\infty` are `t=0` (with ramification degree `1`)
     121    and `t=\infty` (with degree `l`).  The ramification above `j=0`
     122    and `j=1728` may be seen in the factorizations of `j(t)` and
     123    `k(t)` where `k=j-1728`.
     124
     125    OUTPUT:
     126
     127    The rational function `P(t)/t`.
     128
     129    TESTS::
     130
     131        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import Fricke_module
     132        sage: Fricke_module(2)
     133        (t^3 + 48*t^2 + 768*t + 4096)/t
     134        sage: Fricke_module(3)
     135        (t^4 + 36*t^3 + 270*t^2 + 756*t + 729)/t
     136        sage: Fricke_module(5)
     137        (t^6 + 30*t^5 + 315*t^4 + 1300*t^3 + 1575*t^2 + 750*t + 125)/t
     138        sage: Fricke_module(7)
     139        (t^8 + 28*t^7 + 322*t^6 + 1904*t^5 + 5915*t^4 + 8624*t^3 + 4018*t^2 + 748*t + 49)/t
     140        sage: Fricke_module(13)
     141        (t^14 + 26*t^13 + 325*t^12 + 2548*t^11 + 13832*t^10 + 54340*t^9 + 157118*t^8 + 333580*t^7 + 509366*t^6 + 534820*t^5 + 354536*t^4 + 124852*t^3 + 15145*t^2 + 746*t + 13)/t
     142    """
     143    try:       
     144        t = PolynomialRing(QQ,'t').gen()
     145        return Fricke_polynomial(l) / t
     146    except ValueError:
     147        raise ValueError, "The only genus zero primes are 2, 3, 5, 7 or 13."
     148
     149@cached_function
     150def Psi(l, use_stored=True):
     151    r"""
     152    Generic kernel polynomial for genus one primes.
     153
     154    For each of the primes `l` for which `X_0(l)` has genus zero
     155    (namely `l=2,3,5,7,13`), we may define an elliptic curve `E_t`
     156    over `\QQ(t)`, with coefficients in `\ZZ[t]`, which has good
     157    reduction except at `t=0` and `t=\infty` (which lie above
     158    `j=\infty`) and at certain other values of `t` above `j=0` when
     159    `l=3` (one value) or `l\equiv1\pmod{3}` (two values) and above
     160    `j=1728` when `l=2` (one value) or `l\equiv1 \pmod{4}` (two
     161    values).  (These exceptional values correspond to endomorphisms of
     162    `E_t` of degree `l`.)  The `l`-division polynomial of `E_t` has a
     163    unique factor of degree `(l-1)/2` (or 1 when `l=2`), with
     164    coefficients in `\ZZ[t]`, which we call the Generic Kernel
     165    Polynomial for `l`.  These are used, by specialising `t`, in the
     166    function :meth:`isogenies_prime_degree_genus_0`, which also has to
     167    take into account the twisting factor between `E_t` for a specific
     168    value of `t` and the short Weierstrass form of an elliptic curve
     169    with `j`-invariant `j(t)`.  This enables the computation of the
     170    kernel polynomials of isogenies without having to compute and
     171    factor division polynomials.
     172
     173    All of this data is quickly computed from the Fricke modules, except
     174    that for `l=13` the factorization of the Generic Division Polynomial
     175    takes a long time, so the value have been precomputed and cached; by
     176    default the cached values are used, but the code here will recompute
     177    them when ``use_stored`` is ``False``, as in the doctests.
     178
     179    INPUT:
     180
     181    - ``l`` -- either 2, 3, 5, 7, or 13.
     182
     183    - ``use_stored`` (boolean, default True) -- If True, use
     184      precomputed values, otherwise compute them on the fly.
     185
     186    .. note:: 
     187   
     188       This computation takes a negligible time for `l=2,3,5,7'
     189       but more than 100s for `l=13`.  The reason
     190       for allowing dynamic computation here instead of just using
     191       precomputed values is for testing.
     192
     193    TESTS::
     194
     195        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import Fricke_module, Psi
     196        sage: assert Psi(2, use_stored=True) == Psi(2, use_stored=False)
     197        sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
     198        sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
     199        sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
     200        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
     201    """
     202    if not l in [2,3,5,7,13]:
     203        raise ValueError, "Genus zero primes are 2, 3, 5, 7 or 13."
     204
     205    R = PolynomialRing(ZZ,2,'Xt')
     206    X,t = R.gens()
     207
     208    if use_stored:
     209        if l==2:
     210            return X + t + 64
     211        if l==3:
     212            return X + t + 27
     213        if l==5:
     214            return X**2 + 2*X*(t**2 + 22*t + 125)+ (t**2 + 22*t + 89) * (t**2 + 22*t + 125)
     215        if l==7:
     216            return (X**3 + 3*(t**2 + 13*t + 49)*X**2
     217                    + 3*(t**2 + 13*t + 33)*(t**2 + 13*t + 49)*X
     218                    + (t**2 + 13*t + 49)*(t**4 + 26*t**3 + 219*t**2 + 778*t + 881))
     219        if l==13:
     220            return (t**24 + 66*t**23 + 2091*t**22 + 6*X*t**20 + 42582*t**21 + 330*X*t**19 + 627603*t**20 + 8700*X*t**18 + 7134744*t**19 + 15*X**2*t**16 + 146886*X*t**17 + 65042724*t**18 + 660*X**2*t**15 + 1784532*X*t**16 + 487778988*t**17 + 13890*X**2*t**14 + 16594230*X*t**15 + 3061861065*t**16 + 20*X**3*t**12 + 186024*X**2*t**13 + 122552328*X*t**14 + 16280123754*t**15 + 660*X**3*t**11 + 1774887*X**2*t**12 + 735836862*X*t**13 + 73911331425*t**14 + 10380*X**3*t**10 + 12787272*X**2*t**11 + 3646188342*X*t**12 + 287938949178*t**13 + 15*X**4*t**8 + 102576*X**3*t**9 + 71909658*X**2*t**10 + 15047141292*X*t**11 + 964903805434*t**12 + 330*X**4*t**7 + 707604*X**3*t**8 + 321704316*X**2*t**9 + 51955096824*X*t**10 + 2781843718722*t**11 + 3435*X**4*t**6 + 3582876*X**3*t**7 + 1155971196*X**2*t**8 + 150205315932*X*t**9 + 6885805359741*t**10 + 6*X**5*t**4 + 21714*X**4*t**5 + 13632168*X**3*t**6 + 3343499244*X**2*t**7 + 362526695094*X*t**8 + 14569390179114*t**9 + 66*X**5*t**3 + 90660*X**4*t**4 + 39215388*X**3*t**5 + 7747596090*X**2*t**6 + 725403501318*X*t**7 + 26165223178293*t**8 + 336*X**5*t**2 + 255090*X**4*t**3 + 84525732*X**3*t**4 + 14206132008*X**2*t**5 + 1189398495432*X*t**6 + 39474479008356*t**7 + X**6 + 858*X**5*t + 472143*X**4*t**2 + 132886992*X**3*t**3 + 20157510639*X**2*t**4 + 1569568001646*X*t**5 + 49303015587132*t**6 + 1014*X**5 + 525954*X**4*t + 144222780*X**3*t**2 + 21320908440*X**2*t**3 + 1622460290100*X*t**4 + 49941619724976*t**5 + 272259*X**4 + 96482100*X**3*t + 15765293778*X**2*t**2 + 1260038295438*X*t**3 + 39836631701295*t**4 + 29641924*X**3 + 7210949460*X**2*t + 686651250012*X*t**2 + 23947528862166*t**3 + 1506392823*X**2 + 231462513906*X*t + 10114876838391*t**2 + 35655266790*X + 2644809206442*t + 317295487717)
     221# The coefficients for l=13 are:
     222# X**6: 1
     223# X**5: (6) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13)
     224# X**4: (3) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13) * (5*t**4 + 55*t**3 + 260*t**2 + 583*t + 537)
     225# X**3: (4) * (t**2 + 5*t + 13) * (t**2 + 6*t + 13)**2 * (5*t**6 + 80*t**5 + 560*t**4 + 2214*t**3 + 5128*t**2 + 6568*t + 3373)
     226# X**2: (3) * (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**2 * (5*t**8 + 110*t**7 + 1045*t**6 + 5798*t**5 + 20508*t**4 + 47134*t**3 + 67685*t**2 + 54406*t + 17581)
     227# X**1: (6) * (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**3 * (t**10 + 27*t**9 + 316*t**8 + 2225*t**7 + 10463*t**6 + 34232*t**5 + 78299*t**4 + 122305*t**3 + 122892*t**2 + 69427*t + 16005)
     228# X**0: (t**2 + 5*t + 13)**2 * (t**2 + 6*t + 13)**3 * (t**14 + 38*t**13 + 649*t**12 + 6844*t**11 + 50216*t**10 + 271612*t**9 + 1115174*t**8 + 3520132*t**7 + 8549270*t**6 + 15812476*t**5 + 21764840*t**4 + 21384124*t**3 + 13952929*t**2 + 5282630*t + 854569)
     229#
     230
     231    # Here the generic kernel polynomials are actually calculated:
     232    j = Fricke_module(l)
     233    k = j-1728
     234    from sage.misc.all import prod
     235    f = prod( [p for p,e in j.factor() if e==3]
     236             +[p for p,e in k.factor() if e==2])
     237    A4 = -3*t**2*j*k // f**2
     238    A6 = -2*t**3*j*k**2 // f**3
     239    E = EllipticCurve([0,0,0,A4,A6])
     240    assert E.j_invariant() == j
     241    return E.division_polynomial(l,X).factor()[0][0]
     242
     243
     244def isogenies_prime_degree_genus_0(E, l=None):
     245    """
     246    Returns list of ``l`` -isogenies with domain ``E``.
     247
     248    INPUT:
     249
     250    - ``E`` -- an elliptic curve.
     251
     252    - ``l`` -- either None or 2, 3, 5, 7, or 13.
     253
     254    OUTPUT:
     255
     256    (list) When ``l`` is None a list of all isogenies of degree 2, 3,
     257    5, 7 and 13, otherwise a list of isogenies of the given degree.
     258
     259    .. note::
     260
     261       This function would normally be invoked indirectly via
     262       ``E.isogenies_prime_degree(l)``, which automatically calls the
     263       appropriate function.
     264
     265    EXAMPLES::
     266   
     267        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_prime_degree_genus_0
     268        sage: E = EllipticCurve([0,12])
     269        sage: isogenies_prime_degree_genus_0(E, 5)
     270        []
     271
     272        sage: E = EllipticCurve('1450c1')   
     273        sage: isogenies_prime_degree_genus_0(E)   
     274        [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 300*x - 1000 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 5950*x - 182250 over Rational Field]
     275
     276        sage: E = EllipticCurve('50a1')   
     277        sage: isogenies_prime_degree_genus_0(E) 
     278        [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 - x - 2 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 126*x - 552 over Rational Field,
     279        Isogeny of degree 5 from Elliptic Curve defined by y^2 + x*y + y = x^3 - x - 2 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 76*x + 298 over Rational Field]
     280    """
     281    if not l in [2, 3, 5, 7, 13, None]:
     282        raise ValueError, "Isogenies must be of degree 2, 3, 5, 7 or 13."
     283    F = E.base_ring()
     284    j = E.j_invariant()
     285    if F.characteristic() in [2, 3, l]:
     286        raise NotImplementedError, "2, 3, 5, 7 and 13-isogenies are not yet implemented in characteristic 2 and 3, and when the characteristic is the same as the degree of the isogeny."
     287    if l==2:
     288        return isogenies_2(E)
     289    if l==3:
     290        return isogenies_3(E)
     291    if j==F(0):
     292        if l==5:
     293            return isogenies_5_0(E)
     294        if l==7:
     295            return isogenies_7_0(E)
     296        if l==13:
     297            return isogenies_13_0(E)
     298    if j==F(1728):
     299        if l==5:
     300            return isogenies_5_1728(E)
     301        if l==7:
     302            return isogenies_7_1728(E)
     303        if l==13:
     304            return isogenies_13_1728(E)
     305 
     306    if l != None:
     307        R = PolynomialRing(F,'t')
     308        t = R.gen()
     309        f = R(Fricke_polynomial(l))
     310        t_list = (f-j*t).roots(multiplicities=False)
     311        t_list.sort()
     312        # The generic kernel polynomial applies to a standard curve
     313        # E_t with the correct j-invariant; we must compute the
     314        # appropriate twising factor to scale X by:
     315        c4, c6 = E.c_invariants()
     316        T = c4/(3*c6)
     317        jt = Fricke_module(l)
     318        kt = jt-1728
     319        from sage.misc.all import prod
     320        psi = Psi(l)
     321        X = t
     322        f = R(prod( [p for p,e in jt.factor() if e==3]
     323                 +[p for p,e in kt.factor() if e==2]))
     324        kernels = [R(psi(X*T*(j-1728)*t0/f(t0),t0)) for t0 in t_list]
     325        kernels = [ker.monic() for ker in kernels]
     326        E1 = EllipticCurve([-27*c4,-54*c6])
     327        w = E.isomorphism_to(E1)
     328        model = "minimal" if F is QQ else None
     329        isogs = [E1.isogeny(kernel=ker, model=model) for ker in kernels]
     330        [isog.set_pre_isomorphism(w) for isog in isogs]
     331        return isogs
     332
     333    if l == None:
     334        return sum([isogenies_prime_degree_genus_0(E, l) for l in [2,3,5,7,13]],[])
     335
     336
     337# The following is data to be used in isogenies_sporadic_Q. Over Q
     338# there are only finitely many j-invariants of curves with l-isogenies
     339# where l is not equal to 2, 3, 5, 7 or 13. In these cases l is equal
     340# to 11, 17, 19, 37, 43, 67 or 163. We refer to these l as "sporadic".
     341#
     342# isog_table is indexed by the possible sporadic (l,j) pairs and lists
     343# ((a4,a6),f) where (a4,a6) are the invariants of a short Weierstrass
     344# model of one curve with that j-invariant,and f is the factor of
     345# degree (l-1)/2 of the l-division polynomial of that curve. Then
     346# whenever we have a curve of that j-invariant, we can compute the
     347# corresponding l-isogeny by just scaling f by the right twisting
     348# factor and using the result as a kernel-polynomial.
     349
     350# Sample code to precompute this data.  Note that working over ZZ
     351# instead of QQ is a lot faster (in Sage 4.2):
     352#
     353#sage: j = -297756989/2; l = 17
     354#sage: E = EllipticCurve(ZZ,EllipticCurve(j=j).short_weierstrass_model().ainvs())
     355#sage: E.division_polynomial(l,polygen(ZZ)).factor()[1][0].coefficients()
     356#
     357#sage: j = -884736000; l = 43
     358#sage: E = EllipticCurve(ZZ,EllipticCurve(j=j).short_weierstrass_model().ainvs())
     359#sage: E.division_polynomial(l,polygen(ZZ)).factor()[1][0].coefficients()
     360
     361
     362isog_table = dict()
     363
     364isog_table[(11,QQ('-32768'))] = ([-9504, 365904], [1294672896, -92835072, 1463616, 7920, -264, 1])
     365
     366isog_table[(11,QQ('-121'))] = ([-3267, -280962], [1480352841, -56169531, -2829222, 10890, 429, 1])
     367
     368isog_table[(11,QQ('-24729001'))] = ([-38907, -2953962], [-20349931239, -424530315, -134838, 53658, 429, 1])
     369
     370isog_table[(17,QQ('-297756989/2'))] = ([-3940515, 3010787550], [-6458213126940667330314375, 34699336325466068070000, -72461450055340471500, 68342601718080000, -15140380554450, -25802960400, 23981220, -8160, 1])
     371
     372isog_table[(17,QQ('-882216989/131072'))] = ([-856035, -341748450], [103687510635057329105625, 961598491955315190000, 1054634146768300500, -6553122389064000, -14554350284850, -2046589200, 13185540, 8160, 1])
     373
     374isog_table[(19,QQ('-884736'))] = ([-608, 5776], [-34162868224, -8540717056, 6405537792, -1123778560, 84283392, -2033152, -92416, 6992, -152, 1])
     375
     376isog_table[(37,QQ('-9317'))] = ([-10395, 444150],[-38324677699334121599624973029296875, -17868327793500376961572310472656250, 2569568362004197901139023084765625, -95128267987528547588017818750000, -822168183291347061312510937500, 134395594560592096297190625000, -2881389756919344324888937500, -2503855007083401977250000, 922779077075655997443750, -11503912310262102937500, -18237870962450291250, 1457822151548910000, -10087015556047500, -13677678063000, 490243338900, -2461460400, 5198445, -4410, 1])
     377
     378isog_table[(37,QQ('-162677523113838677'))] = ([-269675595, -1704553285050], [-31653754873248632711650187487655160190139073510876609346911928661154296875/37, -1469048260972089939455942042937882262144594798448952781325533511718750, -1171741935131505774747142644126089902595908234671576131857702734375, -574934780393177024547076427530739751753985644656221274606250000, -193516922725803688001809624711400287605136013195315374687500, -47085563820928456130325308223963045033502182349693125000, -8472233937388712980597845725196873697064639957437500, -1124815211213953261752081095348112305023653750000, -105684015609077608033913080859605951322531250, -5911406027236569746089675554748135312500, 22343907270397352965399097794968750, 43602171843758666292581116410000, 5054350766002463251474186500, 350135768194635636171000, 16633063574896677300, 549939627039600, 12182993865, 163170, 1])
     379
     380isog_table[(43,QQ('-884736000'))] = ([-13760, 621264],[-1961864562041980324821547425314935668736, 784270445793223959453256359333693751296, -120528107728500223255333768387027271680, 10335626145581464192664472924270362624, -568426570575654606865505142156820480, 21261993723422650574629752537088000, -544630471727787626557612832587776, 8870521306520473088172555763712, -54993059067301585878494740480, -1434261324709904840432549888, 50978938193065926383894528, -845761855773797582372864, 8627493611216601088000, -48299605284169187328, -32782260293713920, 3415534989828096, -34580115625984, 199359712512, -730488128, 1658080, -2064, 1])
     381
     382isog_table[(67,QQ('-147197952000'))] = ([-117920, 15585808], [426552448394636714720553816389274308035895411389805883034985546818882031845376, -55876556222880738651382959148329502876096075327084935039031884373558741172224, 3393295715290183821010552313572221545212247684503012173117764703828786020352, -125729166452196578653551230178028570067747190427221869867485520072257044480, 3121342502030777257351089270834971957072933779704445667351054593298530304, -52544031605544530265465344472543470442324636919759253720520768014516224, 532110915869155495738137756847596184665209453108323879594125221167104, -399031158106622651277981701966309467713625045637309782055519780864, -101914346170769215732007802723651742508893380955930030421292613632, 2296526155500449624398016447877283594461904009374321659789443072, -31950871094301541469458501953701002806003991982768349794795520, 329792235011603804948028315065667439678526339671142107709440, -2655636715955021784085217734679612378726442691190553837568, 16825164648840434987220620681420687654501026066872664064, -81705027839007003131400500185224450729843244954288128, 273656504606483403474090105104132405333665144373248, -320807702482945680116212224172370503903312084992, -3166683390779345463318656135338172047199043584, 27871349428383710305216046431806697565585408, -132774697798318602604125735604528772808704, 436096215568182871014215818309741314048, -964687143341252402362763535357837312, 942144169187362941776488535425024, 2794850106281773765892648206336, -17236916236678037389276086272, 50979778712911923486851072, -105035658611718440992768, 161833913559276412928, -188675698610077696, 163929317513984, -102098677888, 42387952, -10184, 1])
     383
     384isog_table[(163,QQ('-262537412640768000'))] = ([-34790720, 78984748304], [11937033609701771608400008302859181021419097217821452062564326844817505228663098831008549807845273606080544999996020379100442085010011180910986311230744539492209201267851475053850145465949031314131282944262561686476431332761205504055553653209756637748416809823347727611717499380045401030656, -195130071447306655273524569473852352290010571088570084255929596426827972913675959924834214553822436039185267072655230231264389277855757579340840680919752147359277865429131554516271296434318501723193704667609983954393732283396979741770275596479169906167026623493287956522391758781645062144, 1427502734760154784443139998885173873805698542265553947708985997014264802221336771918193375050938963016560184673026895611200993837000754187703921657388546609660768979949394789838000919808563779734300559653270446650866261801622261730386746625133970663551831816512698564779980290036596736, -5599207432852992026535855102327743354503965526118767584653806869099469434869389394471452436350209911401734358692516268244363981178003440912521398279843764610451103952982463228121628686179444592844803463454880601969041617668281227800515971090274318968755339891485627349912827843313664, 7275289443663173375117187980461451723630939807433676133488193878209459535146604043302393215325736700753114238886326617501903060793779318898498537340122928915051396994852249905774785383484964157718761647679761326405167986820403416875550489904598260809039588027484880575324789669888, 53852767252251176711316610474871670511285949778037067647446607721301053062542360857644949076379793988972999080753585666268471181395581176311086709516236139859119228114940726664020344711163961450649040900179940667704933096423082541578086102752168151408016128448757608609516355584, -441024601763314150109608522830440149169771622404264936395215000306188259683627792348927267455527449622616337194882061278315837263834842622422058957336768392927319786456429412773335490683756389242358011775192147290260088212928183893496023497385031567935590156495818971603271680, 1923729652470036657640234466480856403679261373466564217770510758620007251234737653848912112257887106718711179570266106782165127910894792855741763009046440188368346201617134183692667813264354753020558715833289878752200363206184231817927249353441775148372373391040829093576704, -6174291905252822700639099970860178217904525535465573253756653994759145320917644436646210500761314537511653465341404223911052812759676375813287317189557074876672717009913962857515263325087926781282727274494599622098970326546685474959128901831166082055481492871737587531776, 15963605433939241348215386312076502855685142708851007052060264896693306401589916424547272907372369971200908960298559196028000249867821387055883338894215055448441454208145184664251082508258481820123154014612667230187589409024581605410594578299015578613903351914203971584, -34687777075075826936035422448136670540047824478867437603900549472003349053758981331083701038247602826434094223697740838012005963350495346494192086319952577715870471857062004211165110944749546489357024333327851492892063261902845789001287880518909468079710544890691584, 64935614565701660925102862834870557968917923758048315817978089985628103203452108238400473842703675144415856702414743965076964752315718880263247146806212144113325233966196430978981658754610129252819800656290540439882400228191972297000590950499022332532802841477120, -106450113192928986500166510746460290010686605565802553549898115364953461571938149159855780359758326598170956839310849727549767334328481520722457671184262149140997347199434067316119593873464084542168958564857207310255104210252802288265107074620056433232296542208, 154588468341182819097156049664780175805765082709542906853062319968823210709884467518965950031344875777123989196305422245441384128571495551803479155842444104959551491130118809781140758556182128829570214830557657320822341658937375265326185627024588353675722752, -200559814675071715715147513664537685696543665835231560123119674695431140901874837885144270078673500682009909076723885595600964688749788075855566556738418513204701882392037282897429720984011892144438563658741417367819609826485149957684720592798005782904832, 233913230287794067984901680255098952718268709897211662836962202594844321932231309396660409956864579218254273924904394011519168528453166798219739516110916032144001430976170021740673624911101610999174313953331179592523559209806130064362331035786304028672, -246353703535830799051965068435640665615241585380168769205605419959931340172791084855084136413845436489354260626697043416419953596294256639939636661074827002386688825389366314922889935515780006872313799807871034941783710991661439846743406825846079488, 234982742638283161239147075499923192184558615040750093346909554959954534765162320677404212311317141015056956519607730625264033505832417237335526289717986324622989530401755659861160278474288472483456460761582961131223878005034852988312569782468608, -203278213565303083958289848507904983111914464281937008996800600743049033135780053019308180654889993715847194782810638377233384956677984229396984592095978852141937402724743415866647478390224972086303117541277057454016741537801255285401042550784, 159421011266364165773350759598961923468646295930442671951663830439105229019095602850806206849694626149081055860876320252885592409781300283802068036284087012054926328984117466238728138017296876920468741929209733382315316048593848804000661504, -113020918346823224387675962727710849438448560054728764538889949910907956081636084818673918939857811981198128625134001275445247927733612860826192033364144709296859805908448480126055187856540001252440723696556907592809391568682658983575552, 71945777186858148520189111385851657591994785437936790663752048596268908397761761228530149720647914698227096033298596468433406211022425872184679773706985835273196359946527329295352840585601589987654250252509940697181497393634479177728, -40553506248279853197899380016510447069205875473858373944916667311741237594752103405195544436215283638784303466518029972315361472909380024525230365389883507930702477745185560842399992120410631726800835247081534888734998176190169088, 19639696188973552762819015734509385187497753279018359326954702329472344393424778261565226791972589248949076879073752940457430177635689762236418319921157145929450429275277598105096782299310906043071624518383647513981402864418816, -7557145635717782395604678688732309739123765964398036300935902895029921544449817739871127195837816246027098669576710973724603305169613035210748794125702623638061784934800621663541549758981147547220745886014319375033833619456, 1657074863449131529294393850366914004166071540911557375298352670995793916631379837217699843183161870412953109096989706473414891817476345269315000071815674837414249807862563049048940888990780356828116926372826050377809920, 594537607406738614488647166334439665406200193881374352383582637957395810395355986219181323336507140663007282377906531198753011484726171889166159296232442266402815351908351664480142997422997116094990105400004717838336, -1063381335685557601789471169771716160614658527547206527560235661204306306147122486589145738731952820149525220010993135210540125800587297277176980780550749659568216404307556497848427558893515024809067113577642459136, 866504016710397283549081797838552191017551170056714418172658679484342314216337494688411296133019156758665490378562995489461120013841310945167448587950589192882728019730184100760635093600626150305226434294054912, -544456451437710104677464982275658569122639544706468906698603670935572135268235880234260773620839923609980624261711876187191086008709319550421652238153751371247896403810296918434808016324776218527300472274944, 291391938923983436973777049837536733140215048414562274102609644110225500962890424001140034799254161420207705596799832439286323749581485058440291289292376834767289200150488260103720502388531610043446984704, -137669336373928330264003425607593379960726875901008061728935571651808147336578784033262243606118618305155146994101199276509296485578362621442124562716722538959248783675765430495753630524650420015464448, 58305039769563586190846386880024028458953483779423358562963969531061253550565868881984384427294827940260948562007946246585988242539388915757370599713569828414708265704775708180369817440224330907648, -22263674613297409152475382098514675408629524088165884591926938276387287183647211206514841583522457779552325379611699721363009213935995055122374833256328128159685068070573439567341889102047870976, 7659525572873653643686667682470156611730287715779213959462404612107764289631014622079262434509991525269350939684751076168111178931547830737285816290499346814316593688339716060537705476390912, -2356369509601030092354164626593105564281508081035914666378162646456624099153984023946457193322861690246151591627985138670141283491665875837349056368982626874320059053912723460560567402496, 636306064623878566247238117586667093960745761448319133509756604897082306674457051834692637631208787669480579961449146859307914219525683813169045631019945325543755784485150162136596480, -144354698667964959131302121388611435649331689922451077357726958728526160763985021377919777057073652734054824995380136026354322489788621439866623621032883911971992887755746217820160, 24121955586756417060840806312875152536841537469465641066665477185642959713399102667004561835703554642486033432650174169972215286732914841507194929969333501923213681889898397696, -1062982554332400020436047718307967606435230424325029173087078414691100152298424407470637592479633445244263771003475924500470457802708388802132021409732119617604143984672768, -1289959173517591900879403877417447464323361120695839905879179383576917611515563011791770601288187258710836960962551744314331281738572022125094897455138775637822772609024, 713094034093241133139975542207369737377005379966568397923649557581354608722973890056780743426440880397949894405054289149004564424971813787111450018625163532324306944, -254627379967901645020979419858451704766383325190491161773871149760504423262065255127251316663797380198173202687716259997416292667070368594859769612820620832145408, 73141763506085097918144459824978126154049420184880822723900482544151820781804249152002290712777719695036970656528265835764223704583688284269989955443519127552, -17838537225679516940483486695156689114251551141417084228356667456567223074797422210814066353881812352204911178711536306766419580650031647883778868599848960, 3732949472404613028683276858400771022649020140479952475050562287824228475488013407594597423014344735572239887680502683815016952233794807477380489150464, -658090831088275932021697572468169724648153295038942023393017242911882324988827102897240587742441233130939688197251981440661637431663180512231424000, 91044773494274344573228085560493548892450695165631132364575161840790371925870648417274049055693061297980952723608086693629684733411639066361856, -7206875978668204173369106020317806614830036116031258178074085756310402308591937698714169573782276745187407867676712962154996289706219536384, -819751497058465540849522914081577930969395072622202448379227754265195552229316711754131018363430793506957620878700584807196119659446272, 524492219141524596329431820120551446539246304466694008535436881375050446937946483408452355745347329681867559263476448413099237572608, -144831995016562693238485974645571530330971707229081912571899541756458417275452663670185243929333997861822834344607487043313860608, 29914869637979316056234691641068533246353548074478964560456384907200155525359490145390698951538414992573246875654471802683392, -5051703199007242317980870828294675665554938059871421101373455640671888804716466166733214891733545898164243959713215021056, 704266224450794229753813389400889235502895246267920454892105495898823500254340026026030392861415807391779452916596736, -77090914220067457257437168730743598007998214624866646138957596697882331770536104168830311427039146990575867133952, 5185529715527985800186976473360862373518426289807725150611458977619779754244941008386724289180811582624497664, 253997773097193639890870939442154039645526260966991421810387625142025920490445698037959549218977356972032, -167663051891371188948811201282888303918118872228509878481620659513761819092806840088343319460416847872, 37111139278046773379558801627698801653586358926939257719148812112681156722739468064234356797865984, -6094794232647488071603134809336879629321484740792083961518604911291776122012806633249006682112, 837291566508665017874331015912241564512130987193765470835615200761060354034220082158108672, -100296887606046826616864046733353580911852480578758327196473644505408067503452896362496, 10671531126308719182671886696772003009468978048122050876385337250105289881860177920, -1017660211057522997139542974021461951590281854561469513981031668621068390629376, 87341651749945752980300268787472991750253192293865191008561736741703122944, -6755055811837604655292473395831392832731215030180150346004905802596352, 470435697396489049890276884918878813522261509046808135502735081472, -29431936259973770189795237369002643735145492537132570738950144, 1647955729708147681608319291051493831298410618099083509760, -82151504501901440318090519089275042334656836617109504, 3621394962905672351516373383975280471835697741824, -139946424433346723333934826799658073276284928, 4689146702972667351768128807176661303296, -134326059738838559898371882636836864, 3230090486862617839209120497664, -63628315178835325152092160, 992573003659549935360, -11668560578458368, 95539651616, -472048, 1])
     385
     386
     387
     388def isogenies_sporadic_Q(E, l=None):
     389    """
     390    Returns list of ``l`` -isogenies with domain ``E`` (defined over `\QQ`).
     391
     392    Returns a list of sporadic l-isogenies from E (l = 11, 17, 19, 37,
     393    43, 67 or 163). Only for elliptic curves over `\QQ`.
     394
     395    INPUT:
     396
     397    - ``E`` -- an elliptic curve defined over `\QQ`.
     398
     399    - ``l`` -- either None or a prime number.
     400
     401    OUTPUT:
     402
     403    (list) If ``l`` is None, a list of all isogenies with domain ``E``
     404    and of degree 11, 17, 19, 37, 43, 67 or 163; otherwise a list of
     405    isogenies of the given degree.
     406
     407    .. note::
     408
     409       This function would normally be invoked indirectly via
     410       ``E.isogenies_prime_degree(l)``, which automatically calls the appropriate
     411       function.
     412
     413    EXAMPLES::
     414
     415        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_sporadic_Q                                                                       
     416        sage: E = EllipticCurve('121a1')   
     417        sage: isogenies_sporadic_Q(E, 11)
     418        [Isogeny of degree 11 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 30*x - 76 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 305*x + 7888 over Rational Field]
     419        sage: isogenies_sporadic_Q(E, 13)
     420        []
     421        sage: isogenies_sporadic_Q(E, 17)
     422        []
     423        sage: isogenies_sporadic_Q(E)   
     424        [Isogeny of degree 11 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 30*x - 76 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 305*x + 7888 over Rational Field]
     425         
     426        sage: E = EllipticCurve([1, 1, 0, -660, -7600])   
     427        sage: isogenies_sporadic_Q(E, 17)
     428        [Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 660*x - 7600 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 878710*x + 316677750 over Rational Field]
     429        sage: isogenies_sporadic_Q(E)   
     430        [Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 660*x - 7600 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 878710*x + 316677750 over Rational Field]
     431        sage: isogenies_sporadic_Q(E, 11)
     432        []
     433       
     434        sage: E = EllipticCurve([0, 0, 1, -1862, -30956])   
     435        sage: isogenies_sporadic_Q(E, 11)
     436        []
     437        sage: isogenies_sporadic_Q(E, 19)
     438        [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
     439        sage: isogenies_sporadic_Q(E)   
     440        [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
     441
     442        sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
     443        sage: E.conductor()
     444        19600
     445        sage: isogenies_sporadic_Q(E,37)
     446        [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
     447
     448        sage: E = EllipticCurve([1, 1, 0, -25178045, 48616918750])
     449        sage: E.conductor()                                       
     450        148225
     451        sage: isogenies_sporadic_Q(E,37)
     452        [Isogeny of degree 37 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 25178045*x + 48616918750 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 - 970*x - 13075 over Rational Field]
     453
     454        sage: E = EllipticCurve([-3440, 77658])         
     455        sage: E.conductor()                   
     456        118336
     457        sage: isogenies_sporadic_Q(E,43)       
     458        [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
     459
     460        sage: E = EllipticCurve([-29480, -1948226])     
     461        sage: E.conductor()
     462        287296
     463        sage: isogenies_sporadic_Q(E,67)
     464        [Isogeny of degree 67 from Elliptic Curve defined by y^2 = x^3 - 29480*x - 1948226 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 132335720*x + 585954296438 over Rational Field]
     465
     466        sage: E = EllipticCurve([-34790720, -78984748304])
     467        sage: E.conductor()
     468        425104
     469        sage: isogenies_sporadic_Q(E,163)
     470        [Isogeny of degree 163 from Elliptic Curve defined by y^2 = x^3 - 34790720*x - 78984748304 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 924354639680*x + 342062961763303088 over Rational Field]
     471    """
     472    if E.base_ring() != QQ:
     473        raise ValueError, "The elliptic curve must be defined over QQ."
     474    j = E.j_invariant()
     475    j = QQ(j)
     476    if l != None:
     477        if not l.is_prime():
     478            raise ValueError("%s is not prime."%l)
     479        if not isog_table.has_key((l,j)):
     480            return []
     481        Ew = E.short_weierstrass_model()
     482        E_to_Ew = E.isomorphism_to(Ew)
     483        c4, c6 = Ew.c_invariants()
     484        (a4,a6), f = isog_table[(l,j)]
     485        d = (c6*a4)/(18*c4*a6) # twisting factor
     486        R = PolynomialRing(E.base_field(),'X')
     487        n = len(f)
     488        ker = R([d**(n-i-1) * f[i] for i in range(n)])
     489        isog = Ew.isogeny(kernel=ker, degree=l, model="minimal", check=False)
     490        isog.set_pre_isomorphism(E_to_Ew)
     491        return [isog]
     492    if l is None:
     493        if isog_table.has_key((11,j)):
     494            return isogenies_sporadic_Q(E, Integer(11))
     495        if isog_table.has_key((17,j)):
     496            return isogenies_sporadic_Q(E, Integer(17))
     497        if isog_table.has_key((19,j)):
     498            return isogenies_sporadic_Q(E, Integer(19))
     499        if isog_table.has_key((37,j)):
     500            return isogenies_sporadic_Q(E, Integer(37))
     501        if isog_table.has_key((43,j)):
     502            return isogenies_sporadic_Q(E, Integer(43))
     503        if isog_table.has_key((67,j)):
     504            return isogenies_sporadic_Q(E, Integer(67))
     505        if isog_table.has_key((163,j)):
     506            return isogenies_sporadic_Q(E, Integer(163))
     507        else:
     508            return []
     509
     510def isogenies_2(E):
     511    """
     512    Returns a list of all 2-isogenies with domain ``E``.
     513
     514    INPUT:
     515
     516    - ``E`` -- an elliptic curve.
     517
     518    OUTPUT:
     519
     520    (list) 2-isogenies with domain ``E``.  In general these are
     521    normalised, but over `\QQ` the codomain is a minimal model.
     522
     523    EXAMPLES::
     524
     525        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_2   
     526        sage: E = EllipticCurve('14a1'); E
     527        Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field
     528        sage: [phi.codomain().ainvs() for phi in isogenies_2(E)]
     529        [(1, 0, 1, -36, -70)]
     530
     531        sage: E = EllipticCurve([1,2,3,4,5]); E
     532        Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field
     533        sage: [phi.codomain().ainvs() for phi in isogenies_2(E)]
     534        []
     535        sage: E = EllipticCurve(QQbar, [9,8]); E 
     536        Elliptic Curve defined by y^2 = x^3 + 9*x + 8 over Algebraic Field
     537        sage: isogenies_2(E) # not implemented
     538    """
     539    f2 = E.division_polynomial(2)
     540    x2 = f2.roots(multiplicities=False)
     541    x2.sort()
     542    x = f2.parent().gen()
     543    ff = [x-x2i for x2i in x2]
     544    model = "minimal" if E.base_field() is QQ else None
     545    isogs = [E.isogeny(f, model=model) for f in ff]
     546    return isogs
     547   
     548def isogenies_3(E):
     549    """
     550    Returns a list of all 3-isogenies with domain ``E``.
     551
     552    INPUT:
     553
     554    - ``E`` -- an elliptic curve.
     555
     556    OUTPUT:
     557
     558    (list) 3-isogenies with domain ``E``.  In general these are
     559    normalised, but over `\QQ` the codomain is a minimal model.
     560
     561    EXAMPLES::
     562
     563        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_3
     564        sage: E = EllipticCurve(GF(17), [1,1])
     565        sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
     566        [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1)]
     567
     568        sage: E = EllipticCurve(GF(17^2,'a'), [1,1])
     569        sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
     570        [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1), (0, 0, 0, 5*a + 1, a + 13), (0, 0, 0, 12*a + 6, 16*a + 14)]
     571
     572        sage: E = EllipticCurve('19a1')   
     573        sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
     574        [(0, 1, 1, 1, 0), (0, 1, 1, -769, -8470)]
     575
     576        sage: E = EllipticCurve([1,1])
     577        sage: [phi.codomain().ainvs() for phi in isogenies_3(E)]
     578        []
     579    """
     580    f3 = E.division_polynomial(3)
     581    x3 = f3.roots(multiplicities=False)
     582    x3.sort()
     583    x = f3.parent().gen()
     584    ff = [x-x3i for x3i in x3]
     585    model = "minimal" if E.base_field() is QQ else None
     586    isogs = [E.isogeny(f, model=model) for f in ff]
     587    return isogs
     588
     589# 6 special cases: `l` = 5, 7, 13 and `j` = 0, 1728.
     590
     591def isogenies_5_0(E):
     592    """
     593    Returns a list of all the 5-isogenies  with domain ``E`` when the
     594    j-invariant is 0.
     595
     596    OUTPUT:
     597
     598    (list) 5-isogenies with codomain E.  In general these are
     599    normalised, but over `\QQ` the codomain is a minimal model.
     600
     601    .. note::
     602
     603       This implementation requires that the characteristic is not 2,
     604       3 or 5.
     605
     606    .. note::
     607
     608       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(5)``.
     609
     610    EXAMPLES::
     611
     612        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_5_0
     613        sage: E = EllipticCurve([0,12])
     614        sage: isogenies_5_0(E)                             
     615        []
     616
     617        sage: E = EllipticCurve(GF(13^2,'a'),[0,-3])
     618        sage: isogenies_5_0(E)
     619        [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (4*a+6)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (12*a+5)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (10*a+2)*x + (2*a+10) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (3*a+12)*x + (11*a+12) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (a+4)*x + (11*a+12) over Finite Field in a of size 13^2, Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (9*a+10)*x + (11*a+12) over Finite Field in a of size 13^2]
     620
     621        sage: K.<a> = NumberField(x**6-320*x**3-320)
     622        sage: E = EllipticCurve(K,[0,0,1,0,0])
     623        sage: isogenies_5_0(E)                     
     624        [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 = x^3 + (a^5-400*a^2)*x + (280*a^3-3120) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320,
     625        Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 = x^3 + (23/2*a^5-3700*a^2)*x + (-280*a^3+86480) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320]
     626
     627    """
     628    F = E.base_field()
     629    if E.j_invariant() != 0:
     630        raise ValueError, "j-invariant must be 0."
     631    if F.characteristic() in [2,3,5]:
     632        raise NotImplementedError, "Not implemented in characteristic 2, 3 or 5."
     633    if not F(5).is_square():
     634        return []
     635    Ew = E.short_weierstrass_model()
     636    a = Ew.a6()
     637    x = polygen(F)
     638    betas = (x**6-160*a*x**3-80*a**2).roots(multiplicities=False)
     639    betas.sort()
     640    if len(betas)==0:
     641        return []
     642    gammas = [(beta**2 *(beta**3-140*a))/(120*a) for beta in betas]
     643    model = "minimal" if F is QQ else None
     644    isogs = [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
     645    iso = E.isomorphism_to(Ew)
     646    [isog.set_pre_isomorphism(iso) for isog in isogs]
     647    return isogs
     648
     649def isogenies_5_1728(E):
     650    """
     651    Returns a list of 5-isogenies with domain ``E`` when the j-invariant is
     652    1728.
     653
     654    OUTPUT:
     655
     656    (list) 5-isogenies with codomain E.  In general these are
     657    normalised; but if `-1` is a square then there are two
     658    endomorphisms of degree `5`, for which the codomain is the same as
     659    the domain curve; and over `\QQ`, the codomain is a minimal model.
     660
     661    .. note::
     662
     663       This implementation requires that the characteristic is not 2,
     664       3 or 5.
     665
     666    .. note::
     667
     668       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(5)``.
     669
     670    EXAMPLES::
     671       
     672        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_5_1728
     673        sage: E = EllipticCurve([7,0])   
     674        sage: isogenies_5_1728(E)
     675        []
     676
     677        sage: E = EllipticCurve(GF(13),[11,0])
     678        sage: isogenies_5_1728(E)       
     679        [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13,
     680        Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13]
     681
     682    An example of endomorphisms of degree 5::
     683
     684        sage: K.<i> = QuadraticField(-1)                   
     685        sage: E = EllipticCurve(K,[0,0,0,1,0])
     686        sage: isogenies_5_1728(E)             
     687        [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1,
     688        Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1]
     689        sage: _[0].rational_maps()
     690        (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)),
     691         ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y + (141/125*i + 162/125)*x^2*y + (3/25*i - 4/25)*y)/(x^6 + (-6/5*i + 3/5)*x^4 + (-12/25*i - 9/25)*x^2 + (2/125*i - 11/125)))
     692
     693    An example of 5-isogenies over a number field::
     694
     695        sage: K.<a> = NumberField(x**4+20*x**2-80)
     696        sage: K(5).is_square() #necessary but not sufficient!       
     697        True
     698        sage: E = EllipticCurve(K,[0,0,0,1,0])   
     699        sage: isogenies_5_1728(E)                 
     700        [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 to Elliptic Curve defined by y^2 = x^3 + (-20*a^2-39)*x + (35*a^3+112*a) over Number Field in a with defining polynomial x^4 + 20*x^2 - 80,
     701        Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 to Elliptic Curve defined by y^2 = x^3 + (-20*a^2-39)*x + (-35*a^3-112*a) over Number Field in a with defining polynomial x^4 + 20*x^2 - 80]   
     702    """
     703    F = E.base_field()
     704    if E.j_invariant() != 1728:
     705        raise ValueError, "j-invariant must be 1728."
     706    if F.characteristic() in [2,3,5]:
     707        raise NotImplementedError, "Not implemented in characteristic 2, 3 or 5."
     708    model = "minimal" if F is QQ else None
     709    # quick test for a negative answer (from Fricke module)
     710    square5 = F(5).is_square()
     711    square1 = F(-1).is_square()
     712    if not square5 and not square1:
     713        return []
     714    Ew = E.short_weierstrass_model()
     715    iso = E.isomorphism_to(Ew)
     716    a = Ew.a4()
     717    x = polygen(F)
     718    isogs = []
     719    # 2 cases
     720    # Type 1: if -1 is a square we have 2 endomorphisms
     721    if square1:
     722        i = F(-1).sqrt()
     723        isogs = [Ew.isogeny(f) for f in [x**2+a/(1+2*i), x**2+a/(1-2*i)]]
     724        [isog.set_post_isomorphism(isog.codomain().isomorphism_to(E)) for isog in isogs]
     725    # Type 2: if 5 is a square we have up to 4 (non-endomorphism) isogenies
     726    if square5:
     727        betas = (x**4+20*a*x**2-80*a**2).roots(multiplicities=False)
     728        betas.sort()
     729        gammas = [a*(beta**2-2)/6 for beta in betas]
     730        isogs += [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
     731    [isog.set_pre_isomorphism(iso) for isog in isogs]
     732    return isogs
     733
     734def isogenies_7_0(E):
     735    """
     736    Returns list of all 7-isogenies from E when the j-invariant is 0.
     737
     738    OUTPUT:
     739
     740    (list) 7-isogenies with codomain E.  In general these are
     741    normalised; but if `-3` is a square then there are two
     742    endomorphisms of degree `7`, for which the codomain is the same as
     743    the domain; and over `\QQ`, the codomain is a minimal model.
     744
     745    .. note::
     746
     747       This implementation requires that the characteristic is not 2,
     748       3 or 7.
     749
     750    .. note::
     751
     752       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(7)``.
     753
     754    EXAMPLES:
     755
     756    First some examples of endomorphisms::
     757
     758        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_7_0   
     759        sage: K.<r> = QuadraticField(-3)
     760        sage: E = EllipticCurve(K, [0,1]) 
     761        sage: isogenies_7_0(E)
     762        [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3,
     763        Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3]
     764
     765        sage: E = EllipticCurve(GF(13^2,'a'),[0,-3])
     766        sage: isogenies_7_0(E)       
     767        [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2, Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2]
     768
     769    Now some examples of 7-isogenies which are not endomorphisms::
     770
     771        sage: K = GF(101)               
     772        sage: E = EllipticCurve(K, [0,1])
     773        sage: isogenies_7_0(E)           
     774        [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 55*x + 100 over Finite Field of size 101, Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 83*x + 26 over Finite Field of size 101]
     775
     776    Examples over a number field::
     777
     778        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_7_0
     779        sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r'))
     780        sage: isogenies_7_0(E)
     781        [Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3,
     782        Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3]
     783
     784        sage: K.<a> = NumberField(x^6 + 1512*x^3 - 21168)
     785        sage: E = EllipticCurve(K, [0,1])
     786        sage: isogs = isogenies_7_0(E)
     787        sage: [phi.codomain().a_invariants() for phi in isogs]
     788        [(0, 0, 0, -5/294*a^5 - 300/7*a^2, -55/2*a^3 - 1133),
     789        (0, 0, 0, -295/1176*a^5 - 5385/14*a^2, 55/2*a^3 + 40447)]
     790        sage: [phi.codomain().j_invariant() for phi in isogs]
     791        [158428486656000/7*a^3 - 313976217600000,
     792        -158428486656000/7*a^3 - 34534529335296000]
     793    """
     794    if E.j_invariant()!=0:
     795        raise ValueError, "j-invariant must be 0."
     796    F = E.base_field()
     797    if F.characteristic() in [2,3,7]:
     798        raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 7."
     799    x = polygen(F)
     800    Ew = E.short_weierstrass_model()
     801    iso = E.isomorphism_to(Ew)
     802    a = Ew.a6()
     803    model = "minimal" if F is QQ else None
     804
     805    # there will be 2 endomorphisms if -3 is a square:
     806
     807    ts = (x**2+3).roots(multiplicities=False)
     808    ts.sort()
     809    kers = [7*x-(2+6*t) for t in ts]
     810    kers = [k(x**3/a).monic() for k in kers]
     811    isogs = [Ew.isogeny(k,model=model) for k in kers]
     812    if len(isogs)>0:
     813        [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
     814
     815    # we may have up to 6 other isogenies:
     816    ts = (x**2-21).roots(multiplicities=False)
     817    for t0 in ts:
     818        s3 = a/(28+6*t0)
     819        ss = (x**3-s3).roots(multiplicities=False)
     820        ss.sort()
     821        ker = x**3 - 2*t0*x**2 - 4*t0*x + 4*t0 + 28
     822        kers = [ker(x/s).monic() for s in ss]
     823        isogs += [Ew.isogeny(k, model=model) for k in kers]
     824   
     825    [isog.set_pre_isomorphism(iso) for isog in isogs]
     826    return isogs
     827
     828def isogenies_7_1728(E):
     829    """
     830    Returns list of all 7-isogenies from E when the j-invariant is 1728.
     831
     832    OUTPUT:
     833
     834    (list) 7-isogenies with codomain E.  In general these are
     835    normalised; but over `\QQ` the codomain is a minimal model.
     836
     837    .. note::
     838
     839       This implementation requires that the characteristic is not 2,
     840       3, or 7.
     841
     842    .. note::
     843
     844       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(7)``.
     845
     846    EXAMPLES::
     847
     848        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_7_1728                                                                           
     849        sage: E = EllipticCurve(GF(47), [1, 0])
     850        sage: isogenies_7_1728(E)             
     851        [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 26 over Finite Field of size 47,
     852        Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 21 over Finite Field of size 47]
     853
     854    An example in characteristic 53 (for which an earlier implementation did not work)::   
     855
     856        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_7_1728
     857        sage: E = EllipticCurve(GF(53), [1, 0])
     858        sage: isogenies_7_1728(E)
     859        []
     860        sage: E = EllipticCurve(GF(53^2,'a'), [1, 0])
     861        sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)]
     862        [(0, 0, 0, 36, 19*a + 15), (0, 0, 0, 36, 34*a + 38), (0, 0, 0, 33, 39*a + 28), (0, 0, 0, 33, 14*a + 25), (0, 0, 0, 19, 45*a + 16), (0, 0, 0, 19, 8*a + 37), (0, 0, 0, 3, 45*a + 16), (0, 0, 0, 3, 8*a + 37)]
     863
     864    ::   
     865
     866        sage: K.<a> = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567)
     867        sage: E = EllipticCurve(K, [1, 0])                               
     868        sage: isogs = isogenies_7_1728(E)
     869        sage: [phi.codomain().a_invariants() for phi in isogs]
     870        [(0,
     871        0,
     872        0,
     873        35/636*a^6 + 55/12*a^4 - 79135/636*a^2 + 1127/212,
     874        155/636*a^7 + 245/12*a^5 - 313355/636*a^3 - 3577/636*a),
     875        (0,
     876        0,
     877        0,
     878        35/636*a^6 + 55/12*a^4 - 79135/636*a^2 + 1127/212,
     879        -155/636*a^7 - 245/12*a^5 + 313355/636*a^3 + 3577/636*a)]
     880        sage: [phi.codomain().j_invariant() for phi in isogs]
     881        [-526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53,
     882        -526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53]
     883        sage: E1 = isogs[0].codomain()
     884        sage: E2 = isogs[1].codomain()
     885        sage: E1.is_isomorphic(E2)
     886        False
     887        sage: E1.is_quadratic_twist(E2)
     888        -1
     889    """
     890    if E.j_invariant()!=1728:
     891        raise ValueError, "j_invariant must be 1728 (in base field)."
     892    F = E.base_field()
     893    if F.characteristic() in [2,3,7]:
     894        raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 7."
     895    Ew = E.short_weierstrass_model()
     896    iso = E.isomorphism_to(Ew)
     897    a = Ew.a4()
     898
     899    ts = (Fricke_module(7)-1728).numerator().roots(F,multiplicities=False)
     900    if len(ts)==0:
     901        return []
     902    ts.sort()
     903    isogs = []
     904    model = "minimal" if F is QQ else None
     905    x = polygen(F)
     906    for t0 in ts:
     907        s2 = a/t0
     908        ss = (x**2-s2).roots(multiplicities=False)
     909        ss.sort()
     910        ker = 9*x**3 + (-3*t0**3 - 36*t0**2 - 123*t0)*x**2 + (-8*t0**3 - 101*t0**2 - 346*t0 + 35)*x - 7*t0**3 - 88*t0**2 - 296*t0 + 28
     911
     912        kers = [ker(x/s) for s in ss]
     913        isogs += [Ew.isogeny(k.monic(), model=model) for k in kers]
     914    [isog.set_pre_isomorphism(iso) for isog in isogs]
     915    return isogs
     916
     917def isogenies_13_0(E):
     918    """
     919    Returns list of all 13-isogenies from E when the j-invariant is 0.
     920
     921    OUTPUT:
     922
     923    (list) 13-isogenies with codomain E.  In general these are
     924    normalised; but if `-3` is a square then there are two
     925    endomorphisms of degree `13`, for which the codomain is the same
     926    as the domain.
     927
     928    .. note::
     929
     930       This implementation requires that the characteristic is not 2,
     931       3 or 13.
     932
     933    .. note::
     934
     935       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(13)``.
     936
     937    EXAMPLES::
     938
     939        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_13_0 
     940
     941    Endomorphisms of degree 13 will exist when -3 is a square::   
     942
     943        sage: K.<r> = QuadraticField(-3)
     944        sage: E = EllipticCurve(K, [0, r]); E
     945        Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3
     946        sage: isogenies_13_0(E)
     947        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3,
     948        Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3]
     949        sage: isogenies_13_0(E)[0].rational_maps()
     950        (((7/338*r + 23/338)*x^13 + (-164/13*r - 420/13)*x^10 + (720/13*r + 3168/13)*x^7 + (3840/13*r - 576/13)*x^4 + (4608/13*r + 2304/13)*x)/(x^12 + (4*r + 36)*x^9 + (1080/13*r + 3816/13)*x^6 + (2112/13*r - 5184/13)*x^3 + (-17280/169*r - 1152/169)), ((18/2197*r + 35/2197)*x^18*y + (23142/2197*r + 35478/2197)*x^15*y + (-1127520/2197*r - 1559664/2197)*x^12*y + (-87744/2197*r + 5992704/2197)*x^9*y + (-6625152/2197*r - 9085824/2197)*x^6*y + (-28919808/2197*r - 2239488/2197)*x^3*y + (-1990656/2197*r - 3870720/2197)*y)/(x^18 + (6*r + 54)*x^15 + (3024/13*r + 11808/13)*x^12 + (31296/13*r + 51840/13)*x^9 + (487296/169*r - 2070144/169)*x^6 + (-940032/169*r + 248832/169)*x^3 + (1990656/2197*r + 3870720/2197)))
     951
     952    An example of endomorphisms over a finite field::
     953   
     954        sage: K = GF(19^2,'a')
     955        sage: E = EllipticCurve(j=K(0)); E
     956        Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2
     957        sage: isogenies_13_0(E)                   
     958        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2,
     959        Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2]
     960        sage: isogenies_13_0(E)[0].rational_maps()
     961        ((6*x^13 - 6*x^10 - 3*x^7 + 6*x^4 + x)/(x^12 - 5*x^9 - 9*x^6 - 7*x^3 + 5), (-8*x^18*y - 9*x^15*y + 9*x^12*y - 5*x^9*y + 5*x^6*y - 7*x^3*y + 7*y)/(x^18 + 2*x^15 + 3*x^12 - x^9 + 8*x^6 - 9*x^3 + 7))
     962
     963    A previous implementation did not work in some characteristics::   
     964
     965        sage: K = GF(29)
     966        sage: E = EllipticCurve(j=K(0))
     967        sage: isogenies_13_0(E)
     968        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 26*x + 12 over Finite Field of size 29, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 16*x + 28 over Finite Field of size 29]
     969
     970    ::
     971
     972        sage: K = GF(101)                                         
     973        sage: E = EllipticCurve(j=K(0)); E.ainvs()                 
     974        (0, 0, 0, 0, 1)
     975        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
     976        [(0, 0, 0, 64, 36), (0, 0, 0, 42, 66)]
     977
     978    ::
     979
     980        sage: x = polygen(QQ)
     981        sage: f = x^12 + 78624*x^9 - 130308048*x^6 + 2270840832*x^3 - 54500179968
     982        sage: K.<a> = NumberField(f)     
     983        sage: E = EllipticCurve(j=K(0)); E.ainvs()
     984        (0, 0, 0, 0, 1)
     985        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
     986        [(0, 0, 0, -739946459/23857162861049856*a^11 - 2591641747/1062017577504*a^8 + 16583647773233/4248070310016*a^5 - 14310911337/378211388*a^2, 26146225/4248070310016*a^9 + 7327668845/14750244132*a^6 + 174618431365/756422776*a^3 - 378332499709/94552847), (0, 0, 0, 3501275/5964290715262464*a^11 + 24721025/531008788752*a^8 - 47974903745/1062017577504*a^5 - 6773483100/94552847*a^2, 6699581/4248070310016*a^9 + 1826193509/14750244132*a^6 - 182763866047/756422776*a^3 - 321460597/94552847)]
     987    """
     988    if E.j_invariant()!=0:
     989        raise ValueError, "j-invariant must be 0."
     990    F = E.base_field()
     991    if F.characteristic() in [2,3,13]:
     992        raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 13."
     993    Ew = E.short_weierstrass_model()
     994    iso = E.isomorphism_to(Ew)
     995    a = Ew.a6()
     996    model = "minimal" if F is QQ else None
     997    x = polygen(F)
     998
     999    # there will be 2 endomorphisms if -3 is a square:
     1000    ts = (x**2+3).roots(multiplicities=False)
     1001    ts.sort()
     1002    kers = [13*x**2 + (78*t + 26)*x + 24*t + 40 for t in ts]
     1003    kers = [k(x**3/a).monic() for k in kers]
     1004    isogs = [Ew.isogeny(k,model=model) for k in kers]
     1005    if len(isogs)>0:
     1006        [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
     1007 
     1008    # we may have up to 12 other isogenies:
     1009    ts = (x**4 + 7*x**3 + 20*x**2 + 19*x + 1).roots(multiplicities=False)
     1010    ts.sort()
     1011    for t0 in ts:
     1012        s3 = a / (6*t0**3 + 32*t0**2 + 68*t0 + 4)
     1013        ss = (x**3-s3).roots(multiplicities=False)
     1014        ss.sort()
     1015        ker = (x**6 + (20*t0**3 + 106*t0**2 + 218*t0 + 4)*x**5
     1016            + (-826*t0**3 - 4424*t0**2 - 9244*t0 - 494)*x**4
     1017            + (13514*t0**3 + 72416*t0**2 + 151416*t0 + 8238)*x**3
     1018            + (-101948*t0**3 - 546304*t0**2 - 1142288*t0 - 62116)*x**2
     1019            + (354472*t0**3 + 1899488*t0**2 + 3971680*t0 + 215960)*x
     1020            - 459424*t0**3 - 2461888*t0**2 - 5147648*t0 - 279904)
     1021        kers = [ker(x/s).monic() for s in ss]
     1022        isogs += [Ew.isogeny(k, model=model) for k in kers]
     1023   
     1024    [isog.set_pre_isomorphism(iso) for isog in isogs]
     1025
     1026    return isogs
     1027
     1028def isogenies_13_1728(E):
     1029    """
     1030    Returns list of all 13-isogenies from E when the j-invariant is 1728.
     1031
     1032    OUTPUT:
     1033
     1034    (list) 13-isogenies with codomain E.  In general these are
     1035    normalised; but if `-1` is a square then there are two
     1036    endomorphisms of degree `13`, for which the codomain is the same
     1037    as the domain; and over `\QQ`, the codomain is a minimal model.
     1038
     1039    .. note::
     1040
     1041       This implementation requires that the characteristic is not
     1042       2, 3 or 13.
     1043
     1044    .. note::
     1045
     1046       This function would normally be invoked indirectly via ``E.isogenies_prime_degree(13)``.
     1047
     1048    EXAMPLES::
     1049
     1050        sage: from sage.schemes.elliptic_curves.isogeny_genus_0 import isogenies_13_1728
     1051
     1052        sage: K.<i> = QuadraticField(-1)
     1053        sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs()
     1054        (0, 0, 0, i, 0)
     1055        sage: isogenies_13_1728(E)
     1056        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1,
     1057        Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 to Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1]
     1058
     1059    ::
     1060
     1061        sage: K = GF(83)
     1062        sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs()
     1063        (0, 0, 0, 5, 0)
     1064        sage: isogenies_13_1728(E)                       
     1065        []
     1066        sage: K = GF(89)                                 
     1067        sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs()
     1068        (0, 0, 0, 5, 0)
     1069        sage: isogenies_13_1728(E)                       
     1070        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89,
     1071        Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89]
     1072
     1073    ::
     1074
     1075        sage: K = GF(23)                                     
     1076        sage: E = EllipticCurve(K, [1,0])                     
     1077        sage: isogenies_13_1728(E)                           
     1078        [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 16 over Finite Field of size 23, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 7 over Finite Field of size 23]
     1079
     1080    ::
     1081
     1082        sage: x = polygen(QQ)
     1083        sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
     1084        sage: K.<a> = NumberField(f)
     1085        sage: E = EllipticCurve(K, [1,0])
     1086        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
     1087        [(0,
     1088        0,
     1089        0,
     1090        11090413835/20943727039698624*a^10 + 32280103535965/55849938772529664*a^8 - 355655987835845/1551387188125824*a^6 + 19216954517530195/5235931759924656*a^4 - 1079766118721735/5936430566808*a^2 + 156413528482727/8080141604822,
     1091        214217013065/82065216155553792*a^11 + 1217882637605/427423000810176*a^9 - 214645003230565/189965778137856*a^7 + 22973355421236025/1282269002430528*a^5 - 2059145797340695/2544184528632*a^3 - 23198483147321/989405094468*a),
     1092        (0,
     1093        0,
     1094        0,
     1095        11090413835/20943727039698624*a^10 + 32280103535965/55849938772529664*a^8 - 355655987835845/1551387188125824*a^6 + 19216954517530195/5235931759924656*a^4 - 1079766118721735/5936430566808*a^2 + 156413528482727/8080141604822,
     1096        -214217013065/82065216155553792*a^11 - 1217882637605/427423000810176*a^9 + 214645003230565/189965778137856*a^7 - 22973355421236025/1282269002430528*a^5 + 2059145797340695/2544184528632*a^3 + 23198483147321/989405094468*a)]
     1097   
     1098    """
     1099    if E.j_invariant()!=1728:
     1100        raise ValueError, "j-invariant must be 1728."
     1101    F = E.base_field()
     1102    if F.characteristic() in [2, 3, 7, 13, 167, 233, 271, 1117]:
     1103        raise NotImplementedError, "Not implemented when the characteristic of the base field is 2, 3 or 13."
     1104    Ew = E.short_weierstrass_model()
     1105    iso = E.isomorphism_to(Ew)
     1106    a = Ew.a4()
     1107    model = "minimal" if F is QQ else None
     1108    x = polygen(F)
     1109
     1110    # we will have two endomorphisms if -1 is a square:
     1111    ts = (x**2+1).roots(multiplicities=False)
     1112    ts.sort()
     1113    kers = [13*x**3 + (-26*i - 13)*x**2 + (-52*i - 13)*x - 2*i - 3 for i in ts]
     1114    kers = [k(x**2/a).monic() for k in kers]
     1115    isogs = [Ew.isogeny(k,model=model) for k in kers]
     1116    if len(isogs)>0:
     1117        [endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
     1118
     1119    # we may have up to 12 other isogenies:
     1120
     1121    ts = (x**6 + 10*x**5 + 46*x**4 + 108*x**3 + 122*x**2 + 38*x - 1).roots(multiplicities=False)
     1122    ts.sort()
     1123    for t0 in ts:
     1124        s2 = a/(66*t0**5 + 630*t0**4 + 2750*t0**3 + 5882*t0**2 + 5414*t0 + 162)
     1125        ss = (x**2-s2).roots(multiplicities=False)
     1126        ss.sort()
     1127        ker = (x**6 + (-66*t0**5 - 630*t0**4 - 2750*t0**3 - 5882*t0**2
     1128              - 5414*t0 - 162)*x**5 + (-21722*t0**5 - 205718*t0**4 -
     1129              890146*t0**3 - 1873338*t0**2 - 1652478*t0 + 61610)*x**4
     1130              + (-3391376*t0**5 - 32162416*t0**4 - 139397232*t0**3 -
     1131              294310576*t0**2 - 261885968*t0 + 6105552)*x**3 +
     1132              (-241695080*t0**5 - 2291695976*t0**4 - 9930313256*t0**3
     1133              - 20956609720*t0**2 - 18625380856*t0 + 469971320)*x**2 +
     1134              (-8085170432*t0**5 - 76663232384*t0**4 -
     1135              332202985024*t0**3 - 701103233152*t0**2 -
     1136              623190845440*t0 + 15598973056)*x - 101980510208*t0**5 -
     1137              966973468160*t0**4 - 4190156868352*t0**3 -
     1138              8843158270336*t0**2 - 7860368751232*t0 + 196854655936)
     1139       
     1140        kers = [ker(x/s).monic() for s in ss]
     1141        isogs += [Ew.isogeny(k, model=model) for k in kers]
     1142
     1143    [isog.set_pre_isomorphism(iso) for isog in isogs]
     1144   
     1145    return isogs