Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/schemes/elliptic_curves/ell_field.py
8820 views
1
r"""
2
Elliptic curves over a general field
3
4
This module defines the class ``EllipticCurve_field``, based on
5
``EllipticCurve_generic``, for elliptic curves over general fields.
6
7
"""
8
9
#*****************************************************************************
10
# Copyright (C) 2006 William Stein <[email protected]>
11
#
12
# Distributed under the terms of the GNU General Public License (GPL)
13
#
14
# http://www.gnu.org/licenses/
15
#*****************************************************************************
16
17
import ell_generic
18
import sage.rings.all as rings
19
from sage.rings.complex_field import is_ComplexField
20
from sage.rings.real_mpfr import is_RealField
21
from constructor import EllipticCurve
22
23
from ell_curve_isogeny import EllipticCurveIsogeny, isogeny_codomain_from_kernel
24
from ell_wp import weierstrass_p
25
26
class EllipticCurve_field(ell_generic.EllipticCurve_generic):
27
28
base_field = ell_generic.EllipticCurve_generic.base_ring
29
30
# Twists: rewritten by John Cremona as follows:
31
#
32
# Quadratic twist allowed except when char=2, j=0
33
# Quartic twist allowed only if j=1728!=0 (so char!=2,3)
34
# Sextic twist allowed only if j=0!=1728 (so char!=2,3)
35
#
36
# More complicated twists exist in theory for char=2,3 and
37
# j=0=1728, but I have never worked them out or seen them used!
38
#
39
40
r"""
41
Twists: rewritten by John Cremona as follows:
42
43
The following twists are implemented:
44
45
- Quadratic twist: except when char=2 and `j=0`.
46
- Quartic twist: only if `j=1728\not=0` (so not if char=2,3).
47
- Sextic twist: only if `j=0\not=1728` (so not if char=2,3).
48
49
More complicated twists exist in theory for char=2,3 and j=0=1728,
50
but are not implemented.
51
"""
52
53
def quadratic_twist(self, D=None):
54
"""
55
Return the quadratic twist of this curve by ``D``.
56
57
INPUT:
58
59
- ``D`` (default None) the twisting parameter (see below).
60
61
In characteristics other than 2, `D` must be nonzero, and the
62
twist is isomorphic to self after adjoining `\sqrt(D)` to the
63
base.
64
65
In characteristic 2, `D` is arbitrary, and the twist is
66
isomorphic to self after adjoining a root of `x^2+x+D` to the
67
base.
68
69
In characteristic 2 when `j=0`, this is not implemented.
70
71
If the base field `F` is finite, `D` need not be specified,
72
and the curve returned is the unique curve (up to isomorphism)
73
defined over `F` isomorphic to the original curve over the
74
quadratic extension of `F` but not over `F` itself. Over
75
infinite fields, an error is raised if `D` is not given.
76
77
EXAMPLES::
78
79
sage: E = EllipticCurve([GF(1103)(1), 0, 0, 107, 340]); E
80
Elliptic Curve defined by y^2 + x*y = x^3 + 107*x + 340 over Finite Field of size 1103
81
sage: F=E.quadratic_twist(-1); F
82
Elliptic Curve defined by y^2 = x^3 + 1102*x^2 + 609*x + 300 over Finite Field of size 1103
83
sage: E.is_isomorphic(F)
84
False
85
sage: E.is_isomorphic(F,GF(1103^2,'a'))
86
True
87
88
A characteristic 2 example::
89
90
sage: E=EllipticCurve(GF(2),[1,0,1,1,1])
91
sage: E1=E.quadratic_twist(1)
92
sage: E.is_isomorphic(E1)
93
False
94
sage: E.is_isomorphic(E1,GF(4,'a'))
95
True
96
97
Over finite fields, the twisting parameter may be omitted::
98
99
sage: k.<a> = GF(2^10)
100
sage: E = EllipticCurve(k,[a^2,a,1,a+1,1])
101
sage: Et = E.quadratic_twist()
102
sage: Et # random (only determined up to isomorphism)
103
Elliptic Curve defined by y^2 + x*y = x^3 + (a^7+a^4+a^3+a^2+a+1)*x^2 + (a^8+a^6+a^4+1) over Finite Field in a of size 2^10
104
sage: E.is_isomorphic(Et)
105
False
106
sage: E.j_invariant()==Et.j_invariant()
107
True
108
109
sage: p=next_prime(10^10)
110
sage: k = GF(p)
111
sage: E = EllipticCurve(k,[1,2,3,4,5])
112
sage: Et = E.quadratic_twist()
113
sage: Et # random (only determined up to isomorphism)
114
Elliptic Curve defined by y^2 = x^3 + 7860088097*x^2 + 9495240877*x + 3048660957 over Finite Field of size 10000000019
115
sage: E.is_isomorphic(Et)
116
False
117
sage: k2 = GF(p^2,'a')
118
sage: E.change_ring(k2).is_isomorphic(Et.change_ring(k2))
119
True
120
"""
121
K=self.base_ring()
122
char=K.characteristic()
123
124
if D is None:
125
if K.is_finite():
126
x = rings.polygen(K)
127
if char==2:
128
# We find D such that x^2+x+D is irreducible. If the
129
# degree is odd we can take D=1; otherwise it suffices to
130
# consider odd powers of a generator.
131
D = K(1)
132
if K.degree()%2==0:
133
D = K.gen()
134
a = D**2
135
while len((x**2+x+D).roots())>0:
136
D *= a
137
else:
138
# We could take a multiplicative generator but
139
# that might be expensive to compute; otherwise
140
# half the elements will do
141
D = K.random_element()
142
while len((x**2-D).roots())>0:
143
D = K.random_element()
144
else:
145
raise ValueError, "twisting parameter D must be specified over infinite fields."
146
else:
147
try:
148
D=K(D)
149
except ValueError:
150
raise ValueError, "twisting parameter D must be in the base field."
151
152
if char!=2 and D.is_zero():
153
raise ValueError, "twisting parameter D must be nonzero when characteristic is not 2"
154
155
if char!=2:
156
b2,b4,b6,b8=self.b_invariants()
157
# E is isomorphic to [0,b2,0,8*b4,16*b6]
158
return EllipticCurve(K,[0,b2*D,0,8*b4*D**2,16*b6*D**3])
159
160
# now char==2
161
if self.j_invariant() !=0: # iff a1!=0
162
a1,a2,a3,a4,a6=self.ainvs()
163
E0=self.change_weierstrass_model(a1,a3/a1,0,(a1**2*a4+a3**2)/a1**3)
164
# which has the form = [1,A2,0,0,A6]
165
assert E0.a1()==K(1)
166
assert E0.a3()==K(0)
167
assert E0.a4()==K(0)
168
return EllipticCurve(K,[1,E0.a2()+D,0,0,E0.a6()])
169
else:
170
raise ValueError, "Quadratic twist not implemented in char 2 when j=0"
171
172
def two_torsion_rank(self):
173
r"""
174
Return the dimension of the 2-torsion subgroup of
175
`E(K)`.
176
177
This will be 0, 1 or 2.
178
179
EXAMPLES::
180
181
sage: E=EllipticCurve('11a1')
182
sage: E.two_torsion_rank()
183
0
184
sage: K.<alpha>=QQ.extension(E.division_polynomial(2).monic())
185
sage: E.base_extend(K).two_torsion_rank()
186
1
187
sage: E.reduction(53).two_torsion_rank()
188
2
189
190
::
191
192
sage: E = EllipticCurve('14a1')
193
sage: E.two_torsion_rank()
194
1
195
sage: K.<alpha>=QQ.extension(E.division_polynomial(2).monic().factor()[1][0])
196
sage: E.base_extend(K).two_torsion_rank()
197
2
198
199
::
200
201
sage: EllipticCurve('15a1').two_torsion_rank()
202
2
203
204
"""
205
f=self.division_polynomial(rings.Integer(2))
206
n=len(f.roots())+1
207
return rings.Integer(n).ord(rings.Integer(2))
208
209
210
def quartic_twist(self, D):
211
r"""
212
Return the quartic twist of this curve by `D`.
213
214
INPUT:
215
216
- ``D`` (must be nonzero) -- the twisting parameter..
217
218
.. note::
219
220
The characteristic must not be 2 or 3, and the `j`-invariant must be 1728.
221
222
EXAMPLES::
223
224
sage: E=EllipticCurve_from_j(GF(13)(1728)); E
225
Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 13
226
sage: E1=E.quartic_twist(2); E1
227
Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 13
228
sage: E.is_isomorphic(E1)
229
False
230
sage: E.is_isomorphic(E1,GF(13^2,'a'))
231
False
232
sage: E.is_isomorphic(E1,GF(13^4,'a'))
233
True
234
"""
235
K=self.base_ring()
236
char=K.characteristic()
237
D=K(D)
238
239
if char==2 or char==3:
240
raise ValueError, "Quartic twist not defined in chars 2,3"
241
242
if self.j_invariant() !=K(1728):
243
raise ValueError, "Quartic twist not defined when j!=1728"
244
245
if D.is_zero():
246
raise ValueError, "quartic twist requires a nonzero argument"
247
248
c4,c6=self.c_invariants()
249
# E is isomorphic to [0,0,0,-27*c4,0]
250
assert c6==0
251
return EllipticCurve(K,[0,0,0,-27*c4*D,0])
252
253
def sextic_twist(self, D):
254
r"""
255
Return the quartic twist of this curve by `D`.
256
257
INPUT:
258
259
- ``D`` (must be nonzero) -- the twisting parameter..
260
261
.. note::
262
263
The characteristic must not be 2 or 3, and the `j`-invariant must be 0.
264
265
EXAMPLES::
266
267
sage: E=EllipticCurve_from_j(GF(13)(0)); E
268
Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 13
269
sage: E1=E.sextic_twist(2); E1
270
Elliptic Curve defined by y^2 = x^3 + 11 over Finite Field of size 13
271
sage: E.is_isomorphic(E1)
272
False
273
sage: E.is_isomorphic(E1,GF(13^2,'a'))
274
False
275
sage: E.is_isomorphic(E1,GF(13^4,'a'))
276
False
277
sage: E.is_isomorphic(E1,GF(13^6,'a'))
278
True
279
"""
280
K=self.base_ring()
281
char=K.characteristic()
282
D=K(D)
283
284
if char==2 or char==3:
285
raise ValueError, "Sextic twist not defined in chars 2,3"
286
287
if self.j_invariant() !=K(0):
288
raise ValueError, "Sextic twist not defined when j!=0"
289
290
if D.is_zero():
291
raise ValueError, "Sextic twist requires a nonzero argument"
292
293
c4,c6=self.c_invariants()
294
# E is isomorphic to [0,0,0,0,-54*c6]
295
assert c4==0
296
return EllipticCurve(K,[0,0,0,0,-54*c6*D])
297
298
def is_quadratic_twist(self, other):
299
r"""
300
Determine whether this curve is a quadratic twist of another.
301
302
INPUT:
303
304
- ``other`` -- an elliptic curves with the same base field as self.
305
306
OUTPUT:
307
308
Either 0, if the curves are not quadratic twists, or `D` if
309
``other`` is ``self.quadratic_twist(D)`` (up to isomorphism).
310
If ``self`` and ``other`` are isomorphic, returns 1.
311
312
If the curves are defined over `\mathbb{Q}`, the output `D` is
313
a squarefree integer.
314
315
.. note::
316
317
Not fully implemented in characteristic 2, or in
318
characteristic 3 when both `j`-invariants are 0.
319
320
EXAMPLES::
321
322
sage: E = EllipticCurve('11a1')
323
sage: Et = E.quadratic_twist(-24)
324
sage: E.is_quadratic_twist(Et)
325
-6
326
327
sage: E1=EllipticCurve([0,0,1,0,0])
328
sage: E1.j_invariant()
329
0
330
sage: E2=EllipticCurve([0,0,0,0,2])
331
sage: E1.is_quadratic_twist(E2)
332
2
333
sage: E1.is_quadratic_twist(E1)
334
1
335
sage: type(E1.is_quadratic_twist(E1)) == type(E1.is_quadratic_twist(E2)) #trac 6574
336
True
337
338
::
339
340
sage: E1=EllipticCurve([0,0,0,1,0])
341
sage: E1.j_invariant()
342
1728
343
sage: E2=EllipticCurve([0,0,0,2,0])
344
sage: E1.is_quadratic_twist(E2)
345
0
346
sage: E2=EllipticCurve([0,0,0,25,0])
347
sage: E1.is_quadratic_twist(E2)
348
5
349
350
::
351
352
sage: F = GF(101)
353
sage: E1 = EllipticCurve(F,[4,7])
354
sage: E2 = E1.quadratic_twist()
355
sage: D = E1.is_quadratic_twist(E2); D!=0
356
True
357
sage: F = GF(101)
358
sage: E1 = EllipticCurve(F,[4,7])
359
sage: E2 = E1.quadratic_twist()
360
sage: D = E1.is_quadratic_twist(E2)
361
sage: E1.quadratic_twist(D).is_isomorphic(E2)
362
True
363
sage: E1.is_isomorphic(E2)
364
False
365
sage: F2 = GF(101^2,'a')
366
sage: E1.change_ring(F2).is_isomorphic(E2.change_ring(F2))
367
True
368
369
A characteristic 3 example::
370
371
sage: F = GF(3^5,'a')
372
sage: E1 = EllipticCurve_from_j(F(1))
373
sage: E2 = E1.quadratic_twist(-1)
374
sage: D = E1.is_quadratic_twist(E2); D!=0
375
True
376
sage: E1.quadratic_twist(D).is_isomorphic(E2)
377
True
378
379
::
380
381
sage: E1 = EllipticCurve_from_j(F(0))
382
sage: E2 = E1.quadratic_twist()
383
sage: D = E1.is_quadratic_twist(E2); D
384
1
385
sage: E1.is_isomorphic(E2)
386
True
387
388
"""
389
from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
390
E = self
391
F = other
392
if not is_EllipticCurve(E) or not is_EllipticCurve(F):
393
raise ValueError, "arguments are not elliptic curves"
394
K = E.base_ring()
395
zero = K.zero_element()
396
if not K == F.base_ring():
397
return zero
398
j=E.j_invariant()
399
if j != F.j_invariant():
400
return zero
401
402
if E.is_isomorphic(F):
403
if K is rings.QQ:
404
return rings.ZZ(1)
405
return K.one_element()
406
407
char=K.characteristic()
408
409
if char==2:
410
raise NotImplementedError, "not implemented in characteristic 2"
411
elif char==3:
412
if j==0:
413
raise NotImplementedError, "not implemented in characteristic 3 for curves of j-invariant 0"
414
D = E.b2()/F.b2()
415
416
else:
417
# now char!=2,3:
418
c4E,c6E = E.c_invariants()
419
c4F,c6F = F.c_invariants()
420
421
if j==0:
422
um = c6E/c6F
423
x=rings.polygen(K)
424
ulist=(x**3-um).roots(multiplicities=False)
425
if len(ulist)==0:
426
D = zero
427
else:
428
D = ulist[0]
429
elif j==1728:
430
um=c4E/c4F
431
x=rings.polygen(K)
432
ulist=(x**2-um).roots(multiplicities=False)
433
if len(ulist)==0:
434
D = zero
435
else:
436
D = ulist[0]
437
else:
438
D = (c6E*c4F)/(c6F*c4E)
439
440
# Normalization of output:
441
442
if D.is_zero():
443
return D
444
445
if K is rings.QQ:
446
D = D.squarefree_part()
447
448
assert E.quadratic_twist(D).is_isomorphic(F)
449
450
return D
451
452
def is_quartic_twist(self, other):
453
r"""
454
Determine whether this curve is a quartic twist of another.
455
456
INPUT:
457
458
- ``other`` -- an elliptic curves with the same base field as self.
459
460
OUTPUT:
461
462
Either 0, if the curves are not quartic twists, or `D` if
463
``other`` is ``self.quartic_twist(D)`` (up to isomorphism).
464
If ``self`` and ``other`` are isomorphic, returns 1.
465
466
.. note::
467
468
Not fully implemented in characteristics 2 or 3.
469
470
EXAMPLES::
471
472
sage: E = EllipticCurve_from_j(GF(13)(1728))
473
sage: E1 = E.quartic_twist(2)
474
sage: D = E.is_quartic_twist(E1); D!=0
475
True
476
sage: E.quartic_twist(D).is_isomorphic(E1)
477
True
478
479
::
480
481
sage: E = EllipticCurve_from_j(1728)
482
sage: E1 = E.quartic_twist(12345)
483
sage: D = E.is_quartic_twist(E1); D
484
15999120
485
sage: (D/12345).is_perfect_power(4)
486
True
487
"""
488
from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
489
E = self
490
F = other
491
if not is_EllipticCurve(E) or not is_EllipticCurve(F):
492
raise ValueError, "arguments are not elliptic curves"
493
K = E.base_ring()
494
zero = K.zero_element()
495
if not K == F.base_ring():
496
return zero
497
j=E.j_invariant()
498
if j != F.j_invariant() or j!=K(1728):
499
return zero
500
501
if E.is_isomorphic(F):
502
return K.one_element()
503
504
char=K.characteristic()
505
506
if char==2:
507
raise NotImplementedError, "not implemented in characteristic 2"
508
elif char==3:
509
raise NotImplementedError, "not implemented in characteristic 3"
510
else:
511
# now char!=2,3:
512
D = F.c4()/E.c4()
513
514
if D.is_zero():
515
return D
516
517
assert E.quartic_twist(D).is_isomorphic(F)
518
519
return D
520
521
def is_sextic_twist(self, other):
522
r"""
523
Determine whether this curve is a sextic twist of another.
524
525
INPUT:
526
527
- ``other`` -- an elliptic curves with the same base field as self.
528
529
OUTPUT:
530
531
Either 0, if the curves are not sextic twists, or `D` if
532
``other`` is ``self.sextic_twist(D)`` (up to isomorphism).
533
If ``self`` and ``other`` are isomorphic, returns 1.
534
535
.. note::
536
537
Not fully implemented in characteristics 2 or 3.
538
539
EXAMPLES::
540
541
sage: E = EllipticCurve_from_j(GF(13)(0))
542
sage: E1 = E.sextic_twist(2)
543
sage: D = E.is_sextic_twist(E1); D!=0
544
True
545
sage: E.sextic_twist(D).is_isomorphic(E1)
546
True
547
548
::
549
550
sage: E = EllipticCurve_from_j(0)
551
sage: E1 = E.sextic_twist(12345)
552
sage: D = E.is_sextic_twist(E1); D
553
575968320
554
sage: (D/12345).is_perfect_power(6)
555
True
556
"""
557
from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve
558
E = self
559
F = other
560
if not is_EllipticCurve(E) or not is_EllipticCurve(F):
561
raise ValueError, "arguments are not elliptic curves"
562
K = E.base_ring()
563
zero = K.zero_element()
564
if not K == F.base_ring():
565
return zero
566
j=E.j_invariant()
567
if j != F.j_invariant() or not j.is_zero():
568
return zero
569
570
if E.is_isomorphic(F):
571
return K.one_element()
572
573
char=K.characteristic()
574
575
if char==2:
576
raise NotImplementedError, "not implemented in characteristic 2"
577
elif char==3:
578
raise NotImplementedError, "not implemented in characteristic 3"
579
else:
580
# now char!=2,3:
581
D = F.c6()/E.c6()
582
583
if D.is_zero():
584
return D
585
586
assert E.sextic_twist(D).is_isomorphic(F)
587
588
return D
589
590
def descend_to(self, K, f=None):
591
r"""
592
Given a subfield `K` and an elliptic curve self defined over a field `L`,
593
this function determines whether there exists an elliptic curve over `K`
594
which is isomorphic over `L` to self. If one exists, it finds it.
595
596
INPUT:
597
598
- `K` -- a subfield of the base field of self.
599
- `f` -- an embedding of `K` into the base field of self.
600
601
OUTPUT:
602
603
Either an elliptic curve defined over `K` which is isomorphic to self
604
or None if no such curve exists.
605
606
.. NOTE::
607
608
This only works over number fields and QQ.
609
610
EXAMPLES::
611
612
sage: E = EllipticCurve([1,2,3,4,5])
613
sage: E.descend_to(ZZ)
614
Traceback (most recent call last):
615
...
616
TypeError: Input must be a field.
617
618
::
619
620
sage: F.<b> = QuadraticField(23)
621
sage: G.<a> = F.extension(x^3+5)
622
sage: E = EllipticCurve(j=1728*b).change_ring(G)
623
sage: E.descend_to(F)
624
Elliptic Curve defined by y^2 = x^3 + (8957952*b-206032896)*x + (-247669456896*b+474699792384) over Number Field in b with defining polynomial x^2 - 23
625
626
::
627
628
sage: L.<a> = NumberField(x^4 - 7)
629
sage: K.<b> = NumberField(x^2 - 7)
630
sage: E = EllipticCurve([a^6,0])
631
sage: E.descend_to(K)
632
Elliptic Curve defined by y^2 = x^3 + 1296/49*b*x over Number Field in b with defining polynomial x^2 - 7
633
634
::
635
636
sage: K.<a> = QuadraticField(17)
637
sage: E = EllipticCurve(j = 2*a)
638
sage: print E.descend_to(QQ)
639
None
640
"""
641
if not K.is_field():
642
raise TypeError, "Input must be a field."
643
if self.base_field()==K:
644
return self
645
j = self.j_invariant()
646
from sage.rings.all import QQ
647
if K == QQ:
648
f = QQ.embeddings(self.base_field())[0]
649
if j in QQ:
650
jbase = QQ(j)
651
else:
652
return None
653
elif f == None:
654
embeddings = K.embeddings(self.base_field())
655
if len(embeddings) == 0:
656
raise TypeError, "Input must be a subfield of the base field of the curve."
657
for g in embeddings:
658
try:
659
jbase = g.preimage(j)
660
f = g
661
break
662
except Exception:
663
pass
664
if f == None:
665
return None
666
else:
667
try:
668
jbase = f.preimage(j)
669
except Exception:
670
return None
671
E = EllipticCurve(j=jbase)
672
E2 = EllipticCurve(self.base_field(), [f(a) for a in E.a_invariants()])
673
if jbase==0:
674
d = self.is_sextic_twist(E2)
675
if d == 1:
676
return E
677
if d == 0:
678
return None
679
Etwist = E2.sextic_twist(d)
680
elif jbase==1728:
681
d = self.is_quartic_twist(E2)
682
if d == 1:
683
return E
684
if d == 0:
685
return None
686
Etwist = E2.quartic_twist(d)
687
else:
688
d = self.is_quadratic_twist(E2)
689
if d == 1:
690
return E
691
if d == 0:
692
return None
693
Etwist = E2.quadratic_twist(d)
694
if Etwist.is_isomorphic(self):
695
try:
696
Eout = EllipticCurve(K, [f.preimage(a) for a in Etwist.a_invariants()])
697
except Exception:
698
return None
699
else:
700
return Eout
701
702
def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True):
703
r"""
704
Returns an elliptic curve isogeny from self.
705
706
The isogeny can be determined in two ways, either by a
707
polynomial or a set of torsion points. The methods used are:
708
709
- Velu's Formulas: Velu's original formulas for computing
710
isogenies. This algorithm is selected by giving as the
711
``kernel`` parameter a point or a list of points which
712
generate a finite subgroup.
713
714
- Kohel's Formulas: Kohel's original formulas for computing
715
isogenies. This algorithm is selected by giving as the
716
``kernel`` parameter a polynomial (or a coefficient list
717
(little endian)) which will define the kernel of the
718
isogeny.
719
720
INPUT:
721
722
- ``E`` - an elliptic curve, the domain of the isogeny to
723
initialize.
724
725
- ``kernel`` - a kernel, either a point in ``E``, a list of points
726
in ``E``, a univariate kernel polynomial or ``None``.
727
If initiating from a domain/codomain, this must be
728
set to None. Validity of input is *not* fully checked.
729
730
- ``codomain`` - an elliptic curve (default:None). If ``kernel`` is
731
None, then this must be the codomain of a separable
732
normalized isogeny, furthermore, ``degree`` must be
733
the degree of the isogeny from ``E`` to ``codomain``.
734
If ``kernel`` is not None, then this must be
735
isomorphic to the codomain of the normalized separable
736
isogeny defined by ``kernel``, in this case, the
737
isogeny is post composed with an isomorphism so that
738
this parameter is the codomain.
739
740
- ``degree`` - an integer (default:None). If ``kernel`` is None,
741
then this is the degree of the isogeny from ``E`` to
742
``codomain``. If ``kernel`` is not None, then this is
743
used to determine whether or not to skip a gcd of the
744
kernel polynomial with the two torsion polynomial of
745
``E``.
746
747
- ``model`` - a string (default:None). Only supported variable is
748
"minimal", in which case if``E`` is a curve over the
749
rationals, then the codomain is set to be the unique
750
global minimum model.
751
752
- ``check`` (default: True) does some partial checks that the
753
input is valid (e.g., that the points
754
defined by the kernel polynomial are
755
torsion); however, invalid input can in some
756
cases still pass, since that the points define
757
a group is not checked.
758
759
OUTPUT:
760
761
An isogeny between elliptic curves. This is a morphism of curves.
762
763
EXAMPLES::
764
765
sage: F = GF(2^5, 'alpha'); alpha = F.gen()
766
sage: E = EllipticCurve(F, [1,0,1,1,1])
767
sage: R.<x> = F[]
768
sage: phi = E.isogeny(x+1)
769
sage: phi.rational_maps()
770
((x^2 + x + 1)/(x + 1), (x^2*y + x)/(x^2 + 1))
771
772
sage: E = EllipticCurve('11a1')
773
sage: P = E.torsion_points()[1]
774
sage: E.isogeny(P)
775
Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field
776
777
sage: E = EllipticCurve(GF(19),[1,1])
778
sage: P = E(15,3); Q = E(2,12);
779
sage: (P.order(), Q.order())
780
(7, 3)
781
sage: phi = E.isogeny([P,Q]); phi
782
Isogeny of degree 21 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19
783
sage: phi(E.random_point()) # all points defined over GF(19) are in the kernel
784
(0 : 1 : 0)
785
786
787
# not all polynomials define a finite subgroup trac #6384
788
sage: E = EllipticCurve(GF(31),[1,0,0,1,2])
789
sage: phi = E.isogeny([14,27,4,1])
790
Traceback (most recent call last):
791
...
792
ValueError: The polynomial does not define a finite subgroup of the elliptic curve.
793
794
An example in which we construct an invalid morphism, which
795
illustrates that the check for correctness of the input is not
796
sufficient. (See trac 11578.)::
797
798
sage: R.<x> = QQ[]
799
sage: K.<a> = NumberField(x^2-x-1)
800
sage: E = EllipticCurve(K, [-13392, -1080432])
801
sage: R.<x> = K[]
802
sage: phi = E.isogeny( (x-564)*(x - 396/5*a + 348/5) )
803
sage: phi.codomain().conductor().norm().factor()
804
5^2 * 11^2 * 3271 * 15806939 * 4169267639351
805
sage: phi.domain().conductor().norm().factor()
806
11^2
807
"""
808
return EllipticCurveIsogeny(self, kernel, codomain, degree, model, check=check)
809
810
811
def isogeny_codomain(self, kernel, degree=None):
812
r"""
813
Returns the codomain of the isogeny from self with given
814
kernel.
815
816
INPUT:
817
818
- ``kernel`` - Either a list of points in the kernel of the isogeny,
819
or a kernel polynomial (specified as a either a
820
univariate polynomial or a coefficient list.)
821
822
- ``degree`` - an integer, (default:None) optionally specified degree
823
of the kernel.
824
825
OUTPUT:
826
827
An elliptic curve, the codomain of the separable normalized
828
isogeny from this kernel
829
830
EXAMPLES::
831
832
sage: E = EllipticCurve('17a1')
833
sage: R.<x> = QQ[]
834
sage: E2 = E.isogeny_codomain(x - 11/4); E2
835
Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 1461/16*x - 19681/64 over Rational Field
836
837
"""
838
return isogeny_codomain_from_kernel(self, kernel, degree=None)
839
840
def isogenies_prime_degree(self, l=None, max_l=31):
841
"""
842
Generic code, valid for all fields, for arbitrary prime `l` not equal to the characteristic.
843
844
INPUT:
845
846
- ``l`` -- either None, a prime or a list of primes.
847
- ``max_l`` -- a bound on the primes to be tested (ignored unless `l` is None).
848
849
OUTPUT:
850
851
(list) All `l`-isogenies for the given `l` with domain self.
852
853
METHOD:
854
855
Calls the generic function
856
``isogenies_prime_degree()``. This requires that
857
certain operations have been implemented over the base field,
858
such as root-finding for univariate polynomials.
859
860
EXAMPLES::
861
862
sage: F = QQbar
863
sage: E = EllipticCurve(F, [1,18]); E
864
Elliptic Curve defined by y^2 = x^3 + x + 18 over Algebraic Field
865
sage: E.isogenies_prime_degree()
866
Traceback (most recent call last):
867
...
868
NotImplementedError: This code could be implemented for QQbar, but has not been yet.
869
870
sage: F = CC
871
sage: E = EllipticCurve(F, [1,18]); E
872
Elliptic Curve defined by y^2 = x^3 + 1.00000000000000*x + 18.0000000000000 over Complex Field with 53 bits of precision
873
sage: E.isogenies_prime_degree(11)
874
Traceback (most recent call last):
875
...
876
NotImplementedError: This code could be implemented for general complex fields, but has not been yet.
877
878
Examples over finite fields::
879
880
sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8])
881
sage: E.isogenies_prime_degree()
882
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003, Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 347438*x + 594729 over Finite Field of size 1000003, Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 674846*x + 7392 over Finite Field of size 1000003, Isogeny of degree 23 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 390065*x + 605596 over Finite Field of size 1000003]
883
sage: E.isogenies_prime_degree(2)
884
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003]
885
sage: E.isogenies_prime_degree(3)
886
[]
887
sage: E.isogenies_prime_degree(5)
888
[]
889
sage: E.isogenies_prime_degree(7)
890
[]
891
sage: E.isogenies_prime_degree(13)
892
[Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003,
893
Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003]
894
895
sage: E.isogenies_prime_degree([2, 3, 5, 7, 13])
896
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003]
897
sage: E.isogenies_prime_degree([2, 4])
898
Traceback (most recent call last):
899
...
900
ValueError: 4 is not prime.
901
sage: E.isogenies_prime_degree(4)
902
Traceback (most recent call last):
903
...
904
ValueError: 4 is not prime.
905
sage: E.isogenies_prime_degree(11)
906
[]
907
sage: E = EllipticCurve(GF(17),[2,0])
908
sage: E.isogenies_prime_degree(3)
909
[]
910
sage: E.isogenies_prime_degree(2)
911
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 9*x over Finite Field of size 17, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 5*x + 9 over Finite Field of size 17, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 5*x + 8 over Finite Field of size 17]
912
913
sage: E = EllipticCurve(GF(13^4, 'a'),[2,8])
914
sage: E.isogenies_prime_degree(2)
915
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field in a of size 13^4, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + (8*a^3+2*a^2+7*a+5)*x + (12*a^3+3*a^2+4*a+4) over Finite Field in a of size 13^4, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + (5*a^3+11*a^2+6*a+11)*x + (a^3+10*a^2+9*a) over Finite Field in a of size 13^4]
916
917
sage: E.isogenies_prime_degree(3)
918
[Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 9*x + 11 over Finite Field in a of size 13^4]
919
920
Example to show that separable isogenies of degree equal to the characteristic are now implemented::
921
922
sage: E.isogenies_prime_degree(13)
923
[Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field in a of size 13^4]
924
925
Examples over number fields (other than QQ)::
926
927
sage: QQroot2.<e> = NumberField(x^2-2)
928
sage: E = EllipticCurve(QQroot2, j=8000)
929
sage: E.isogenies_prime_degree()
930
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-602112000)*x + 5035261952000 over Number Field in e with defining polynomial x^2 - 2,
931
Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (903168000*e-1053696000)*x + (14161674240000*e-23288086528000) over Number Field in e with defining polynomial x^2 - 2,
932
Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-903168000*e-1053696000)*x + (-14161674240000*e-23288086528000) over Number Field in e with defining polynomial x^2 - 2]
933
934
sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E
935
Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2
936
sage: E.isogenies_prime_degree(2)
937
[Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-36)*x + (-70) over Number Field in e with defining polynomial x^2 - 2]
938
sage: E.isogenies_prime_degree(3)
939
[Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-128/3)*x + 5662/27 over Number Field in e with defining polynomial x^2 - 2, Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-171)*x + (-874) over Number Field in e with defining polynomial x^2 - 2]
940
"""
941
F = self.base_ring()
942
if is_RealField(F):
943
raise NotImplementedError, "This code could be implemented for general real fields, but has not been yet."
944
if is_ComplexField(F):
945
raise NotImplementedError, "This code could be implemented for general complex fields, but has not been yet."
946
if F == rings.QQbar:
947
raise NotImplementedError, "This code could be implemented for QQbar, but has not been yet."
948
949
from isogeny_small_degree import isogenies_prime_degree
950
if l is None:
951
from sage.rings.all import prime_range
952
l = prime_range(max_l+1)
953
954
if type(l) != list:
955
try:
956
l = rings.ZZ(l)
957
except TypeError:
958
raise ValueError, "%s is not prime."%l
959
if l.is_prime():
960
return isogenies_prime_degree(self, l)
961
else:
962
raise ValueError, "%s is not prime."%l
963
964
L = list(set(l))
965
try:
966
L = [rings.ZZ(l) for l in L]
967
except TypeError:
968
raise ValueError, "%s is not a list of primes."%l
969
970
L.sort()
971
return sum([isogenies_prime_degree(self,l) for l in L],[])
972
973
def is_isogenous(self, other, field=None):
974
"""
975
Returns whether or not self is isogenous to other.
976
977
INPUT:
978
979
- ``other`` -- another elliptic curve.
980
981
- ``field`` (default None) -- Currently not implemented. A
982
field containing the base fields of the two elliptic curves
983
onto which the two curves may be extended to test if they
984
are isogenous over this field. By default is_isogenous will
985
not try to find this field unless one of the curves can be
986
be extended into the base field of the other, in which case
987
it will test over the larger base field.
988
989
OUTPUT:
990
991
(bool) True if there is an isogeny from curve ``self`` to
992
curve ``other`` defined over ``field``.
993
994
METHOD:
995
996
Over general fields this is only implemented in trivial cases.
997
998
EXAMPLES::
999
1000
sage: E1 = EllipticCurve(CC, [1,18]); E1
1001
Elliptic Curve defined by y^2 = x^3 + 1.00000000000000*x + 18.0000000000000 over Complex Field with 53 bits of precision
1002
sage: E2 = EllipticCurve(CC, [2,7]); E2
1003
Elliptic Curve defined by y^2 = x^3 + 2.00000000000000*x + 7.00000000000000 over Complex Field with 53 bits of precision
1004
sage: E1.is_isogenous(E2)
1005
Traceback (most recent call last):
1006
...
1007
NotImplementedError: Only implemented for isomorphic curves over general fields.
1008
1009
sage: E1 = EllipticCurve(Frac(PolynomialRing(ZZ,'t')), [2,19]); E1
1010
Elliptic Curve defined by y^2 = x^3 + 2*x + 19 over Fraction Field of Univariate Polynomial Ring in t over Integer Ring
1011
sage: E2 = EllipticCurve(CC, [23,4]); E2
1012
Elliptic Curve defined by y^2 = x^3 + 23.0000000000000*x + 4.00000000000000 over Complex Field with 53 bits of precision
1013
sage: E1.is_isogenous(E2)
1014
Traceback (most recent call last):
1015
...
1016
NotImplementedError: Only implemented for isomorphic curves over general fields.
1017
"""
1018
from ell_generic import is_EllipticCurve
1019
if not is_EllipticCurve(other):
1020
raise ValueError, "Second argument is not an Elliptic Curve."
1021
if self.is_isomorphic(other):
1022
return True
1023
else:
1024
raise NotImplementedError, "Only implemented for isomorphic curves over general fields."
1025
1026
def weierstrass_p(self, prec=20, algorithm=None):
1027
r"""
1028
Computes the Weierstrass `\wp`-function of the elliptic curve.
1029
1030
INPUT:
1031
1032
- ``mprec`` - precision
1033
1034
- ``algorithm`` - string (default:``None``) an algorithm identifier
1035
indicating using the ``pari``, ``fast`` or ``quadratic``
1036
algorithm. If the algorithm is ``None``, then this
1037
function determines the best algorithm to use.
1038
1039
OUTPUT:
1040
1041
a Laurent series in one variable `z` with coefficients in the
1042
base field `k` of `E`.
1043
1044
EXAMPLES::
1045
1046
sage: E = EllipticCurve('11a1')
1047
sage: E.weierstrass_p(prec=10)
1048
z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + 77531/41580*z^8 + O(z^10)
1049
sage: E.weierstrass_p(prec=8)
1050
z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + O(z^8)
1051
sage: Esh = E.short_weierstrass_model()
1052
sage: Esh.weierstrass_p(prec=8)
1053
z^-2 + 13392/5*z^2 + 1080432/7*z^4 + 59781888/25*z^6 + O(z^8)
1054
1055
sage: E.weierstrass_p(prec=8, algorithm='pari')
1056
z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + O(z^8)
1057
sage: E.weierstrass_p(prec=8, algorithm='quadratic')
1058
z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + O(z^8)
1059
1060
sage: k = GF(101)
1061
sage: E = EllipticCurve(k, [2,3])
1062
sage: E.weierstrass_p(prec=30)
1063
z^-2 + 40*z^2 + 14*z^4 + 62*z^6 + 15*z^8 + 47*z^10 + 66*z^12 + 61*z^14 + 79*z^16 + 98*z^18 + 93*z^20 + 82*z^22 + 15*z^24 + 71*z^26 + 27*z^28 + O(z^30)
1064
1065
sage: k = GF(11)
1066
sage: E = EllipticCurve(k, [1,1])
1067
sage: E.weierstrass_p(prec=6, algorithm='fast')
1068
z^-2 + 2*z^2 + 3*z^4 + O(z^6)
1069
sage: E.weierstrass_p(prec=7, algorithm='fast')
1070
Traceback (most recent call last):
1071
...
1072
ValueError: For computing the Weierstrass p-function via the fast algorithm, the characteristic (11) of the underlying field must be greater than prec + 4 = 11.
1073
sage: E.weierstrass_p(prec=8 ,algorithm='pari')
1074
z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8)
1075
sage: E.weierstrass_p(prec=9, algorithm='pari')
1076
Traceback (most recent call last):
1077
...
1078
ValueError: For computing the Weierstrass p-function via pari, the characteristic (11) of the underlying field must be greater than prec + 2 = 11.
1079
1080
"""
1081
return weierstrass_p(self, prec=prec, algorithm=algorithm)
1082
1083
1084
def hasse_invariant(self):
1085
r"""
1086
Returns the Hasse invariant of this elliptic curve.
1087
1088
OUTPUT:
1089
1090
The Hasse invariant of this elliptic curve, as an element of
1091
the base field. This is only defined over fields of positive
1092
characteristic, and is an element of the field which is zero
1093
if and only if the curve is supersingular. Over a field of
1094
characteristic zero, where the Hasse invariant is undefined,
1095
a ``ValueError`` is returned.
1096
1097
EXAMPLES::
1098
1099
sage: E = EllipticCurve([Mod(1,2),Mod(1,2),0,0,Mod(1,2)])
1100
sage: E.hasse_invariant()
1101
1
1102
sage: E = EllipticCurve([0,0,Mod(1,3),Mod(1,3),Mod(1,3)])
1103
sage: E.hasse_invariant()
1104
0
1105
sage: E = EllipticCurve([0,0,Mod(1,5),0,Mod(2,5)])
1106
sage: E.hasse_invariant()
1107
0
1108
sage: E = EllipticCurve([0,0,Mod(1,5),Mod(1,5),Mod(2,5)])
1109
sage: E.hasse_invariant()
1110
2
1111
1112
Some examples over larger fields::
1113
1114
sage: EllipticCurve(GF(101),[0,0,0,0,1]).hasse_invariant()
1115
0
1116
sage: EllipticCurve(GF(101),[0,0,0,1,1]).hasse_invariant()
1117
98
1118
sage: EllipticCurve(GF(103),[0,0,0,0,1]).hasse_invariant()
1119
20
1120
sage: EllipticCurve(GF(103),[0,0,0,1,1]).hasse_invariant()
1121
17
1122
sage: F.<a> = GF(107^2)
1123
sage: EllipticCurve(F,[0,0,0,a,1]).hasse_invariant()
1124
62*a + 75
1125
sage: EllipticCurve(F,[0,0,0,0,a]).hasse_invariant()
1126
0
1127
1128
Over fields of characteristic zero, the Hasse invariant is
1129
undefined::
1130
1131
sage: E = EllipticCurve([0,0,0,0,1])
1132
sage: E.hasse_invariant()
1133
Traceback (most recent call last):
1134
...
1135
ValueError: Hasse invariant only defined in positive characteristic
1136
"""
1137
k = self.base_field()
1138
p = k.characteristic()
1139
if p == 0:
1140
raise ValueError('Hasse invariant only defined in positive characteristic')
1141
elif p == 2:
1142
return self.a1()
1143
elif p == 3:
1144
return self.b2()
1145
elif p == 5:
1146
return self.c4()
1147
elif p == 7:
1148
return -self.c6()
1149
else:
1150
R = k['x']
1151
x = R.gen()
1152
E = self.short_weierstrass_model()
1153
f=(x**3+E.a4()*x+E.a6())**((p-1)//2)
1154
return f.coeffs()[p-1]
1155
1156