This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
ell_rational_field.py
7133 lines (5727 loc) · 259 KB
/
ell_rational_field.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
Elliptic curves over the rational numbers
AUTHORS:
- William Stein (2005): first version
- William Stein (2006-02-26): fixed Lseries_extended which didn't work
because of changes elsewhere in Sage.
- David Harvey (2006-09): Added padic_E2, padic_sigma, padic_height,
padic_regulator methods.
- David Harvey (2007-02): reworked padic-height related code
- Christian Wuthrich (2007): added padic sha computation
- David Roe (2007-09): moved sha, l-series and p-adic functionality to
separate files.
- John Cremona (2008-01)
- Tobias Nagel and Michael Mardaus (2008-07): added integral_points
- John Cremona (2008-07): further work on integral_points
- Christian Wuthrich (2010-01): moved Galois reps and modular
parametrization in a separate file
- Simon Spicer (2013-03): Added code for modular degrees and congruence
numbers of higher level
- Simon Spicer (2014-08): Added new analytic rank computation functionality
"""
##############################################################################
# Copyright (C) 2005,2006,2007 William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
##############################################################################
from __future__ import print_function, division, absolute_import
from six.moves import range
from . import constructor
from . import BSD
from .ell_generic import is_EllipticCurve
from . import ell_modular_symbols
from .ell_number_field import EllipticCurve_number_field
from . import ell_point
from . import ell_tate_curve
from . import ell_torsion
from . import heegner
from .gp_simon import simon_two_descent
from .lseries_ell import Lseries_ell
from . import mod5family
from .modular_parametrization import ModularParameterization
from . import padic_lseries
from . import padics
from sage.modular.modsym.modsym import ModularSymbols
from sage.modular.pollack_stevens.space import ps_modsym_from_elliptic_curve
from sage.lfunctions.zero_sums import LFunctionZeroSum_EllipticCurve
import sage.modular.modform.constructor
import sage.modular.modform.element
import sage.libs.eclib.all as mwrank
import sage.databases.cremona
import sage.arith.all as arith
import sage.rings.all as rings
from sage.rings.all import (
PowerSeriesRing,
infinity as oo,
ZZ, QQ,
Integer,
IntegerRing, RealField,
ComplexField, RationalField)
import sage.misc.all as misc
from sage.misc.all import verbose
from sage.misc.functional import log
import sage.matrix.all as matrix
from sage.libs.pari.all import pari, PariError
from sage.functions.other import gamma_inc
from math import sqrt
from sage.interfaces.all import gp
from sage.misc.cachefunc import cached_method
from copy import copy
Q = RationalField()
C = ComplexField()
R = RealField()
Z = IntegerRing()
IR = rings.RealIntervalField(20)
_MAX_HEIGHT=21
# complex multiplication dictionary:
# CMJ is a dict of pairs (j,D) where j is a rational CM j-invariant
# and D is the corresponding quadratic discriminant
CMJ={ 0: -3, 54000: -12, -12288000: -27, 1728: -4, 287496: -16,
-3375: -7, 16581375: -28, 8000: -8, -32768: -11, -884736: -19,
-884736000: -43, -147197952000: -67, -262537412640768000: -163}
class EllipticCurve_rational_field(EllipticCurve_number_field):
r"""
Elliptic curve over the Rational Field.
INPUT:
- ``ainvs`` -- a list or tuple `[a_1, a_2, a_3, a_4, a_6]` of
Weierstrass coefficients.
.. note::
This class should not be called directly; use
:class:`sage.constructor.EllipticCurve` to construct
elliptic curves.
EXAMPLES:
Construction from Weierstrass coefficients (`a`-invariants), long form::
sage: E = EllipticCurve([1,2,3,4,5]); E
Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field
Construction from Weierstrass coefficients (`a`-invariants),
short form (sets `a_1 = a_2 = a_3 = 0`)::
sage: EllipticCurve([4,5]).ainvs()
(0, 0, 0, 4, 5)
Constructor from a Cremona label::
sage: EllipticCurve('389a1')
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
Constructor from an LMFDB label::
sage: EllipticCurve('462.f3')
Elliptic Curve defined by y^2 + x*y = x^3 - 363*x + 1305 over Rational Field
"""
def __init__(self, ainvs, **kwds):
r"""
Constructor for the EllipticCurve_rational_field class.
TESTS:
When constructing a curve from the large database using a
label, we must be careful that the copied generators have the
right curve (see :trac:`10999`: the following used not to work when
the large database was installed)::
sage: E = EllipticCurve('389a1')
sage: [P.curve() is E for P in E.gens()]
[True, True]
"""
self.__np = {}
self.__gens = {}
self.__rank = {}
self.__regulator = {}
self.__generalized_modular_degree = {}
self.__generalized_congruence_number = {}
self._isoclass = {}
EllipticCurve_number_field.__init__(self, Q, ainvs)
if 'conductor' in kwds:
self._set_conductor(kwds['conductor'])
if 'cremona_label' in kwds:
self._set_cremona_label(kwds['cremona_label'])
if 'gens' in kwds:
self._set_gens(kwds['gens'])
if 'lmfdb_label' in kwds:
self._lmfdb_label = kwds['lmfdb_label']
if 'modular_degree' in kwds:
self._set_modular_degree(kwds['modular_degree'])
if 'rank' in kwds:
self._set_rank(kwds['rank'])
if 'regulator' in kwds:
self.__regulator[True] = kwds['regulator']
if 'torsion_order' in kwds:
self._set_torsion_order(kwds['torsion_order'])
def _set_rank(self, r):
"""
Internal function to set the cached rank of this elliptic curve to
r.
.. warning::
No checking is done! Not intended for use by users.
EXAMPLES::
sage: E = EllipticCurve('37a1')
sage: E._set_rank(99) # bogus value -- not checked
sage: E.rank() # returns bogus cached value
99
sage: E._EllipticCurve_rational_field__rank={} # undo the damage
sage: E.rank() # the correct rank
1
"""
self.__rank = {}
self.__rank[True] = Integer(r)
def _set_torsion_order(self, t):
"""
Internal function to set the cached torsion order of this elliptic
curve to t.
.. warning::
No checking is done! Not intended for use by users.
EXAMPLES::
sage: E=EllipticCurve('37a1')
sage: E._set_torsion_order(99) # bogus value -- not checked
sage: E.torsion_order() # returns bogus cached value
99
sage: T = E.torsion_subgroup() # causes actual torsion to be computed
sage: E.torsion_order() # the correct value
1
"""
self.__torsion_order = Integer(t)
def _set_cremona_label(self, L):
"""
Internal function to set the cached label of this elliptic curve to
L.
.. warning::
No checking is done! Not intended for use by users.
EXAMPLES::
sage: E=EllipticCurve('37a1')
sage: E._set_cremona_label('bogus')
sage: E.label()
'bogus'
sage: label = E.database_attributes()['cremona_label']; label
'37a1'
sage: E.label() # no change
'bogus'
sage: E._set_cremona_label(label)
sage: E.label() # now it is correct
'37a1'
"""
self.__cremona_label = L
def _set_conductor(self, N):
"""
Internal function to set the cached conductor of this elliptic
curve to N.
.. warning::
No checking is done! Not intended for use by users.
Setting to the wrong value will cause strange problems (see
examples).
EXAMPLES::
sage: E=EllipticCurve('37a1')
sage: E._set_conductor(99) # bogus value -- not checked
sage: E.conductor() # returns bogus cached value
99
sage: E._set_conductor(37)
"""
self.__conductor_pari = Integer(N)
def _set_modular_degree(self, deg):
"""
Internal function to set the cached modular degree of this elliptic
curve to deg.
.. warning::
No checking is done!
EXAMPLES::
sage: E=EllipticCurve('5077a1')
sage: E.modular_degree()
1984
sage: E._set_modular_degree(123456789)
sage: E.modular_degree()
123456789
sage: E._set_modular_degree(1984)
"""
self.__modular_degree = Integer(deg)
def _set_gens(self, gens):
"""
Internal function to set the cached generators of this elliptic
curve to gens.
.. warning::
No checking is done!
EXAMPLES::
sage: E=EllipticCurve('5077a1')
sage: E.rank()
3
sage: E.gens() # random
[(-2 : 3 : 1), (-7/4 : 25/8 : 1), (1 : -1 : 1)]
sage: E._set_gens([]) # bogus list
sage: E.rank() # unchanged
3
sage: E._set_gens([E(-2,3), E(-1,3), E(0,2)])
sage: E.gens()
[(-2 : 3 : 1), (-1 : 3 : 1), (0 : 2 : 1)]
"""
self.__gens = {}
self.__gens[True] = [self.point(x, check=True) for x in gens]
self.__gens[True].sort()
def is_p_integral(self, p):
r"""
Returns True if this elliptic curve has `p`-integral
coefficients.
INPUT:
- ``p`` - a prime integer
EXAMPLES::
sage: E=EllipticCurve(QQ,[1,1]); E
Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field
sage: E.is_p_integral(2)
True
sage: E2=E.change_weierstrass_model(2,0,0,0); E2
Elliptic Curve defined by y^2 = x^3 + 1/16*x + 1/64 over Rational Field
sage: E2.is_p_integral(2)
False
sage: E2.is_p_integral(3)
True
"""
if not arith.is_prime(p):
raise ArithmeticError("p must be prime")
if self.is_integral():
return True
return bool(misc.mul([x.valuation(p) >= 0 for x in self.ainvs()]))
def is_integral(self):
"""
Returns True if this elliptic curve has integral coefficients (in
Z)
EXAMPLES::
sage: E=EllipticCurve(QQ,[1,1]); E
Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field
sage: E.is_integral()
True
sage: E2=E.change_weierstrass_model(2,0,0,0); E2
Elliptic Curve defined by y^2 = x^3 + 1/16*x + 1/64 over Rational Field
sage: E2.is_integral()
False
"""
try:
return self.__is_integral
except AttributeError:
one = Integer(1)
self.__is_integral = bool(misc.mul([x.denominator() == 1 for x in self.ainvs()]))
return self.__is_integral
def mwrank(self, options=''):
r"""
Run Cremona's mwrank program on this elliptic curve and return the
result as a string.
INPUT:
- ``options`` (string) -- run-time options passed when starting mwrank.
The format is as follows (see below for examples of usage):
- ``-v n`` (verbosity level) sets verbosity to n (default=1)
- ``-o`` (PARI/GP style output flag) turns ON extra PARI/GP short output (default is OFF)
- ``-p n`` (precision) sets precision to `n` decimals (default=15)
- ``-b n`` (quartic bound) bound on quartic point search (default=10)
- ``-x n`` (n_aux) number of aux primes used for sieving (default=6)
- ``-l`` (generator list flag) turns ON listing of points (default ON unless v=0)
- ``-s`` (selmer_only flag) if set, computes Selmer rank only (default: not set)
- ``-d`` (skip_2nd_descent flag) if set, skips the second descent for curves with 2-torsion (default: not set)
- ``-S n`` (sat_bd) upper bound on saturation primes (default=100, -1 for automatic)
OUTPUT:
- ``string`` - output of mwrank on this curve
.. note::
The output is a raw string and completely illegible using
automatic display, so it is recommended to use print for
legible output.
EXAMPLES::
sage: E = EllipticCurve('37a1')
sage: E.mwrank() #random
...
sage: print(E.mwrank())
Curve [0,0,1,-1,0] : Basic pair: I=48, J=-432
disc=255744
...
Generator 1 is [0:-1:1]; height 0.05111...
Regulator = 0.05111...
The rank and full Mordell-Weil basis have been determined unconditionally.
...
Options to mwrank can be passed::
sage: E = EllipticCurve([0,0,0,877,0])
Run mwrank with 'verbose' flag set to 0 but list generators if
found
::
sage: print(E.mwrank('-v0 -l'))
Curve [0,0,0,877,0] : 0 <= rank <= 1
Regulator = 1
Run mwrank again, this time with a higher bound for point searching
on homogeneous spaces::
sage: print(E.mwrank('-v0 -l -b11'))
Curve [0,0,0,877,0] : Rank = 1
Generator 1 is [29604565304828237474403861024284371796799791624792913256602210:-256256267988926809388776834045513089648669153204356603464786949:490078023219787588959802933995928925096061616470779979261000]; height 95.980371987964
Regulator = 95.980371987964
"""
if options == "":
from sage.interfaces.all import mwrank
else:
from sage.interfaces.all import Mwrank
mwrank = Mwrank(options=options)
return mwrank(list(self.a_invariants()))
def conductor(self, algorithm="pari"):
"""
Returns the conductor of the elliptic curve.
INPUT:
- ``algorithm`` - str, (default: "pari")
- ``"pari"`` - use the PARI C-library ellglobalred
implementation of Tate's algorithm
- ``"mwrank"`` - use Cremona's mwrank implementation
of Tate's algorithm; can be faster if the curve has integer
coefficients (TODO: limited to small conductor until mwrank gets
integer factorization)
- ``"gp"`` - use the GP interpreter.
- ``"generic"`` - use the general number field
implementation
- ``"all"`` - use all four implementations, verify
that the results are the same (or raise an error), and output the
common value.
EXAMPLE::
sage: E = EllipticCurve([1, -1, 1, -29372, -1932937])
sage: E.conductor(algorithm="pari")
3006
sage: E.conductor(algorithm="mwrank")
3006
sage: E.conductor(algorithm="gp")
3006
sage: E.conductor(algorithm="generic")
3006
sage: E.conductor(algorithm="all")
3006
.. note::
The conductor computed using each algorithm is cached
separately. Thus calling ``E.conductor('pari')``, then
``E.conductor('mwrank')`` and getting the same result
checks that both systems compute the same answer.
TESTS::
sage: E.conductor(algorithm="bogus")
Traceback (most recent call last):
...
ValueError: algorithm 'bogus' is not known
"""
if algorithm == "pari":
try:
return self.__conductor_pari
except AttributeError:
self.__conductor_pari = Integer(self.pari_mincurve().ellglobalred()[0])
return self.__conductor_pari
elif algorithm == "gp":
try:
return self.__conductor_gp
except AttributeError:
self.__conductor_gp = Integer(gp.eval('ellglobalred(ellinit(%s,0))[1]'%list(self.a_invariants())))
return self.__conductor_gp
elif algorithm == "mwrank":
try:
return self.__conductor_mwrank
except AttributeError:
if self.is_integral():
self.__conductor_mwrank = Integer(self.mwrank_curve().conductor())
else:
self.__conductor_mwrank = Integer(self.minimal_model().mwrank_curve().conductor())
return self.__conductor_mwrank
elif algorithm == "generic":
try:
return self.__conductor_generic
except AttributeError:
self.__conductor_generic = sage.schemes.elliptic_curves.ell_number_field.EllipticCurve_number_field.conductor(self).gen()
return self.__conductor_generic
elif algorithm == "all":
N1 = self.conductor("pari")
N2 = self.conductor("mwrank")
N3 = self.conductor("gp")
N4 = self.conductor("generic")
if N1 != N2 or N2 != N3 or N2 != N4:
raise ArithmeticError("PARI, mwrank, gp and Sage compute different conductors (%s,%s,%s,%s) for %s"%(
N1, N2, N3, N4, self))
return N1
else:
raise ValueError("algorithm %r is not known"%algorithm)
####################################################################
# Access to PARI curves related to this curve.
####################################################################
def pari_curve(self):
"""
Return the PARI curve corresponding to this elliptic curve.
INPUT:
- ``prec`` -- Deprecated
- ``factor`` -- Deprecated
EXAMPLES::
sage: E = EllipticCurve([0, 0, 1, -1, 0])
sage: e = E.pari_curve()
sage: type(e)
<type 'sage.libs.cypari2.gen.gen'>
sage: e.type()
't_VEC'
sage: e.ellan(10)
[1, -2, -3, 2, -2, 6, -1, 0, 6, 4]
::
sage: E = EllipticCurve(RationalField(), ['1/3', '2/3'])
sage: e = E.pari_curve()
sage: e[:5]
[0, 0, 0, 1/3, 2/3]
When doing certain computations, PARI caches the results::
sage: E = EllipticCurve('37a1')
sage: _ = E.__dict__.pop('_pari_curve', None) # clear cached data
sage: Epari = E.pari_curve()
sage: Epari
[0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [0, 0, 0, 0, 0, 0, 0, 0]]
sage: Epari.omega()
[2.99345864623196, -2.45138938198679*I]
sage: Epari
[0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [[2.99345864623196, -2.45138938198679*I], 0, [0.837565435283323, 0.269594436405445, -1.10715987168877, 1.37675430809421, 1.94472530697209, 0.567970998877878]~, 0, 0, 0, 0, 0]]
This shows that the bug uncovered by :trac:`4715` is fixed::
sage: Ep = EllipticCurve('903b3').pari_curve()
This still works, even when the curve coefficients are large
(see :trac:`13163`)::
sage: E = EllipticCurve([4382696457564794691603442338788106497, 28, 3992, 16777216, 298])
sage: E.pari_curve()
[4382696457564794691603442338788106497, 28, 3992, 16777216, 298, ...]
sage: E.minimal_model()
Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 7686423934083797390675981169229171907674183588326184511391146727143672423167091484392497987721106542488224058921302964259990799229848935835464702*x + 8202280443553761483773108648734271851215988504820214784899752662100459663011709992446860978259617135893103951840830254045837355547141096270521198994389833928471736723050112419004202643591202131091441454709193394358885 over Rational Field
"""
try:
return self._pari_curve
except AttributeError:
self._pari_curve = pari(self.a_invariants()).ellinit()
return self._pari_curve
def pari_mincurve(self):
"""
Return the PARI curve corresponding to a minimal model for this
elliptic curve.
INPUT:
- ``prec`` -- Deprecated
- ``factor`` -- Deprecated
EXAMPLES::
sage: E = EllipticCurve(RationalField(), ['1/3', '2/3'])
sage: e = E.pari_mincurve()
sage: e[:5]
[0, 0, 0, 27, 486]
sage: E.conductor()
47232
sage: e.ellglobalred()
[47232, [1, 0, 0, 0], 2, [2, 7; 3, 2; 41, 1], [[7, 2, 0, 1], [2, -3, 0, 2], [1, 5, 0, 1]]]
"""
try:
return self._pari_mincurve
except AttributeError:
mc, change = self.pari_curve().ellminimalmodel()
self._pari_mincurve = mc
return self._pari_mincurve
@cached_method
def database_attributes(self):
"""
Return a dictionary containing information about ``self`` in
the elliptic curve database.
If there is no elliptic curve isomorphic to ``self`` in the
database, a ``RuntimeError`` is raised.
EXAMPLES::
sage: E = EllipticCurve((0, 0, 1, -1, 0))
sage: data = E.database_attributes()
sage: data['conductor']
37
sage: data['cremona_label']
'37a1'
sage: data['rank']
1
sage: data['torsion_order']
1
sage: E = EllipticCurve((8, 13, 21, 34, 55))
sage: E.database_attributes()
Traceback (most recent call last):
...
RuntimeError: no database entry for Elliptic Curve defined by y^2 + 8*x*y + 21*y = x^3 + 13*x^2 + 34*x + 55 over Rational Field
"""
from sage.databases.cremona import CremonaDatabase
ainvs = self.minimal_model().ainvs()
try:
return CremonaDatabase().data_from_coefficients(ainvs)
except RuntimeError:
raise RuntimeError("no database entry for %s" % self)
def database_curve(self):
"""
Return the curve in the elliptic curve database isomorphic to this
curve, if possible. Otherwise raise a RuntimeError exception.
Since :trac:`11474`, this returns exactly the same curve as
:meth:`minimal_model`; the only difference is the additional
work of checking whether the curve is in the database.
EXAMPLES::
sage: E = EllipticCurve([0,1,2,3,4])
sage: E.database_curve()
Elliptic Curve defined by y^2 = x^3 + x^2 + 3*x + 5 over Rational Field
.. note::
The model of the curve in the database can be different
from the Weierstrass model for this curve, e.g., database
models are always minimal.
"""
try:
return self.__database_curve
except AttributeError:
misc.verbose("Looking up %s in the database."%self)
D = sage.databases.cremona.CremonaDatabase()
ainvs = list(self.minimal_model().ainvs())
try:
self.__database_curve = D.elliptic_curve_from_ainvs(ainvs)
except RuntimeError:
raise RuntimeError("Elliptic curve %s not in the database."%self)
return self.__database_curve
def Np(self, p):
r"""
The number of points on `E` modulo `p`.
INPUT:
- ``p`` (int) -- a prime, not necessarily of good reduction.
OUTPUT:
(int) The number ofpoints on the reduction of `E` modulo `p`
(including the singular point when `p` is a prime of bad
reduction).
EXAMPLES::
sage: E = EllipticCurve([0, -1, 1, -10, -20])
sage: E.Np(2)
5
sage: E.Np(3)
5
sage: E.conductor()
11
sage: E.Np(11)
11
This even works when the prime is large::
sage: E = EllipticCurve('37a')
sage: E.Np(next_prime(10^30))
1000000000000001426441464441649
"""
if self.conductor() % p == 0:
return p + 1 - self.ap(p)
return p+1 - self.ap(p)
#def __pari_double_prec(self):
# EllipticCurve_number_field._EllipticCurve__pari_double_prec(self)
# try:
# del self._pari_mincurve
# except AttributeError:
# pass
####################################################################
# Access to mwrank
####################################################################
def mwrank_curve(self, verbose=False):
"""
Construct an mwrank_EllipticCurve from this elliptic curve
The resulting mwrank_EllipticCurve has available methods from John
Cremona's eclib library.
EXAMPLES::
sage: E=EllipticCurve('11a1')
sage: EE=E.mwrank_curve()
sage: EE
y^2+ y = x^3 - x^2 - 10*x - 20
sage: type(EE)
<class 'sage.libs.eclib.interface.mwrank_EllipticCurve'>
sage: EE.isogeny_class()
([[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]],
[[0, 5, 5], [5, 0, 0], [5, 0, 0]])
"""
try:
return self.__mwrank_curve
except AttributeError:
pass
self.__mwrank_curve = mwrank.mwrank_EllipticCurve(
list(self.ainvs()), verbose=verbose)
return self.__mwrank_curve
def two_descent(self, verbose=True,
selmer_only = False,
first_limit = 20,
second_limit = 8,
n_aux = -1,
second_descent = 1):
"""
Compute 2-descent data for this curve.
INPUT:
- ``verbose`` - (default: True) print what mwrank is
doing. If False, **no output** is printed.
- ``selmer_only`` - (default: False) selmer_only
switch
- ``first_limit`` - (default: 20) firstlim is bound
on x+z second_limit- (default: 8) secondlim is bound on log max
x,z , i.e. logarithmic
- ``n_aux`` - (default: -1) n_aux only relevant for
general 2-descent when 2-torsion trivial; n_aux=-1 causes default
to be used (depends on method)
- ``second_descent`` - (default: True)
second_descent only relevant for descent via 2-isogeny
OUTPUT:
Returns ``True`` if the descent succeeded, i.e. if the lower bound and
the upper bound for the rank are the same. In this case, generators and
the rank are cached. A return value of ``False`` indicates that either
rational points were not found, or that Sha[2] is nontrivial and mwrank
was unable to determine this for sure.
EXAMPLES::
sage: E=EllipticCurve('37a1')
sage: E.two_descent(verbose=False)
True
"""
misc.verbose("Calling mwrank C++ library.")
C = self.mwrank_curve()
C.two_descent(verbose, selmer_only,
first_limit, second_limit,
n_aux, second_descent)
if C.certain():
self.__gens[True] = [self.point(x, check=True) for x in C.gens()]
self.__gens[True].sort()
self.__rank[True] = len(self.__gens[True])
return C.certain()
####################################################################
# Etc.
####################################################################
def aplist(self, n, python_ints=False):
r"""
The Fourier coefficients `a_p` of the modular form
attached to this elliptic curve, for all primes `p\leq n`.
INPUT:
- ``n`` - integer
- ``python_ints`` - bool (default: False); if True
return a list of Python ints instead of Sage integers.
OUTPUT: list of integers
EXAMPLES::
sage: e = EllipticCurve('37a')
sage: e.aplist(1)
[]
sage: e.aplist(2)
[-2]
sage: e.aplist(10)
[-2, -3, -2, -1]
sage: v = e.aplist(13); v
[-2, -3, -2, -1, -5, -2]
sage: type(v[0])
<type 'sage.rings.integer.Integer'>
sage: type(e.aplist(13, python_ints=True)[0])
<type 'int'>
"""
e = self.pari_mincurve()
v = e.ellaplist(n, python_ints=True)
if python_ints:
return v
else:
return [Integer(a) for a in v]
def anlist(self, n, python_ints=False):
"""
The Fourier coefficients up to and including `a_n` of the
modular form attached to this elliptic curve. The i-th element of
the return list is a[i].
INPUT:
- ``n`` - integer
- ``python_ints`` - bool (default: False); if True
return a list of Python ints instead of Sage integers.
OUTPUT: list of integers
EXAMPLES::
sage: E = EllipticCurve([0, -1, 1, -10, -20])
sage: E.anlist(3)
[0, 1, -2, -1]
::
sage: E = EllipticCurve([0,1])
sage: E.anlist(20)
[0, 1, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 8, 0]
"""
n = int(n)
e = self.pari_mincurve()
if n >= 2147483648:
raise RuntimeError("anlist: n (=%s) must be < 2147483648."%n)
v = [0] + e.ellan(n, python_ints=True)
if not python_ints:
v = [Integer(x) for x in v]
return v
# There is some overheard associated with coercing the PARI
# list back to Python, but it's not bad. It's better to do it
# this way instead of trying to eval the whole list, since the
# int conversion is done very sensibly. NOTE: This would fail
# if a_n won't fit in a C int, i.e., is bigger than
# 2147483648; however, we wouldn't realistically compute
# anlist for n that large anyway.
#
# Some relevant timings:
#
# E <--> [0, 1, 1, -2, 0] 389A
# E = EllipticCurve([0, 1, 1, -2, 0]); // Sage or MAGMA
# e = E.pari_mincurve()
# f = ellinit([0,1,1,-2,0]);
#
# Computation Time (1.6Ghz Pentium-4m laptop)
# time v:=TracesOfFrobenius(E,10000); // MAGMA 0.120
# gettime;v=ellan(f,10000);gettime/1000 0.046
# time v=e.ellan (10000) 0.04
# time v=E.anlist(10000) 0.07
# time v:=TracesOfFrobenius(E,100000); // MAGMA 1.620
# gettime;v=ellan(f,100000);gettime/1000 0.676
# time v=e.ellan (100000) 0.7
# time v=E.anlist(100000) 0.83
# time v:=TracesOfFrobenius(E,1000000); // MAGMA 20.850
# gettime;v=ellan(f,1000000);gettime/1000 9.238
# time v=e.ellan (1000000) 9.61
# time v=E.anlist(1000000) 10.95 (13.171 in cygwin vmware)
# time v:=TracesOfFrobenius(E,10000000); //MAGMA 257.850
# gettime;v=ellan(f,10000000);gettime/1000 FAILS no matter how many allocatemem()'s!!
# time v=e.ellan (10000000) 139.37
# time v=E.anlist(10000000) 136.32
#
# The last Sage comp retries with stack size 40MB,
# 80MB, 160MB, and succeeds last time. It's very interesting that this
# last computation is *not* possible in GP, but works in py_pari!
#
def q_expansion(self, prec):
r"""
Return the `q`-expansion to precision prec of the newform
attached to this elliptic curve.
INPUT:
- ``prec`` - an integer
OUTPUT:
a power series (in the variable 'q')
.. note::