All published worksheets from http://sagenb.org
Image: ubuntu2004
Algebraic number theory and related topics
at RIMS, 2010/12/6-10
Sage for Number Theorists
Iwao KIMURA (University of Toyama)
This is a Sage notebook which I gave a demonstration of doing math (number theory) by Sage.
As a calculator
2D Plotting
Interactive plotting
3D graphic
Taken from somewhere...
There are a lot of good looking pictures or plotting drawn by Sage.
Another 3D plotting...
3D interactive graphics are drawn by JMol (Java applet).
Tiny examples of functions (defining and invoking functions)
But this is done by... (Python's "list comprehension")
Cython
---Interface to C---
The example is to compute n-th Harmonic number, the sum of 1/m, m=1,...,n. (cf. Prof. M. Kida's talk on Magma at this workshop, 2008/Dec).
Firstly, pure Sage (Python) version:
One can measure the time to compute something by timeit().
Writing Cython code, one can incorporate C/C++ code into Sage.
The same routine written in C with GMP.
File: /home/iwao/sage-4.5.3-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/_home_iwao__sage_sage_notebook_sagenb_home_admin_3_code_sage31_spyx_0.pyx
Type: <type 'builtin_function_or_method'>
Definition: harmonic( [noargspec] )
Docstring:
C/Cython version seems 120% faster than original Sage version.
The same function can be written without using loop (sum of list version) , this is a bit faster than
original for loop version, but slower than C/Cython version.
Rings, Fields and Polynomials
We can construct the ring of polynomials over Q by several way.
What is 'x'?
Automatic Coercions!
see http://sagemath.blogspot.com/2010/11/brief-history-and-motivation-behind.html
, .
Number Theory
Some standard functionality for algebraic number fields are supplied by Sage. One can invoke pari-gp.
Note that the computation in Sage are done rigorously, in another word, not assuming any unproven hypothesis.
One can specify some parameter to assume some heuristics.
One can invoke pari-gp inside Sage.
pari-gp's quadunit() returns the fundamental unit of real quadratic fields.
Cyclotomic fields
List of subfields of . But the display of outputs seems buggy...(the results is correct).
Dirichlet Characters
One can easily construct a group of Dirichlet characters of given conductor.
By the analytic class number formula for an imaginary abelian field, we can compute
the relative class number of . (, ):
Dr. T. Taniguchi (Gakushuin) will give a lecture on sophisticated way to compute
the relative class numbers of -th cyclotomic fields on 2010/Dec/26 at Kanazawa.
For a number field, Sage provides class_number() function, but this fails sadly ;_;
This is because, as said before, Sage try to compute without any unproven hypothesis.
If one specify 'proof=False' option, Sage (in fact, pari library) computes class numbers
using Heuristic bound for the norm of generators of ideal class group. The result may not
be correct, but almost ok.
Table of Number Fields
Install extra package:
install_package('database_jones_numfield-v4')
File: /home/iwao/sage-4.5.3-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/sage/databases/jones.py
Source Code (starting at line 80):
class JonesDatabase: def __init__(self): self.root = None def __repr__(self): return "John Jones's table of number fields with bounded ramification and degree <= 6" def _load(self, path, filename): print filename i = 0 while filename[i].isalpha(): i += 1 j = len(filename)-1 while filename[j].isalpha() or filename[j] in [".", "_"]: j -= 1 S = [eval(z) for z in filename[i:j+1].split("-")] S.sort() data = open(path + "/" + filename).read() data = data.replace("^","**") x = PolynomialRing(RationalField(), 'x').gen() v = eval(data) s = tuple(S) if self.root.has_key(s): self.root[s] += v self.root[s].sort() else: self.root[s] = v def _init(self, path): """ Create the database from scratch from the PARI files on John Jones's web page, downloaded (e.g., via wget) to a local directory, which is specified as path above. INPUT: - ``path`` - (default works on William Stein install.) path must be the path to Jones's Number_Fields directory http://hobbes.la.asu.edu/Number_Fields These files should have been downloaded using wget. EXAMPLE: This is how to create the database from scratch, assuming that the number fields are in the default directory above: From a cold start of Sage:: sage: J = JonesDatabase() sage: J._init() # not tested ... This takes about 5 seconds. """ n = 0 x = PolynomialRing(RationalField(),'x').gen() self.root = {} self.root[tuple([])] = [x-1] if not os.path.exists(path): raise IOError, "Path %s does not exist."%path for X in os.listdir(path): if X[-4:] == "solo": Z = path + "/" + X print X for Y in os.listdir(Z): if Y[-3:] == ".gp": self._load(Z, Y) if not os.path.exists(JONESDATA): os.makedirs(JONESDATA) save(self.root, JONESDATA+ "/jones.sobj") def unramified_outside(self, S, d=None, var='a'): """ Return all fields in the database of degree d unramified outside S. If d is omitted, return fields of any degree up to 6. The fields are ordered by degree and discriminant. INPUT: - ``S`` - list or set of primes, or a single prime - ``d`` - None (default, in which case all fields of degree <= 6 are returned) or a positive integer giving the degree of the number fields returned. - ``var`` - the name used for the generator of the number fields (default 'a'). EXAMPLES:: sage: J = JonesDatabase() # optional - jones_database sage: J.unramified_outside([101,109]) # optional - jones_database [Number Field in a with defining polynomial x - 1, Number Field in a with defining polynomial x^2 - 101, Number Field in a with defining polynomial x^2 - 109, Number Field in a with defining polynomial x^3 - x^2 - 36*x + 4, Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361, Number Field in a with defining polynomial x^4 - x^3 + 14*x^2 + 34*x + 393, Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6, Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4, Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17] """ try: S = list(S) except TypeError: S = [S] Z = [] for X in powerset(S): Z += self.ramified_at(X, d=d, var=var) Z = [(k.degree(), k.discriminant().abs(), k.discriminant() > 0, k) for k in Z] Z.sort() return [z[-1] for z in Z] def __getitem__(self, S): return self.get(S) def get(self, S, var='a'): """ Return all fields in the database ramified exactly at the primes in S. INPUT: - ``S`` - list or set of primes, or a single prime - ``var`` - the name used for the generator of the number fields (default 'a'). EXAMPLES:: sage: J = JonesDatabase() # optional - jones_database sage: J.get(163, var='z') # optional - jones_database [Number Field in z with defining polynomial x^2 + 163, Number Field in z with defining polynomial x^3 - x^2 - 54*x + 169, Number Field in z with defining polynomial x^4 - x^3 - 7*x^2 + 2*x + 9] sage: J.get([3, 4]) # optional - jones_database Traceback (most recent call last): ... ValueError: S must be a list of primes """ if self.root is None: if os.path.exists(JONESDATA+ "/jones.sobj"): self.root = load(JONESDATA+ "/jones.sobj") else: raise RuntimeError, "You must install the Jones database optional package." try: S = list(S) except TypeError: S = [S] if not all([p.is_prime() for p in S]): raise ValueError, "S must be a list of primes" S.sort() s = tuple(S) if not self.root.has_key(s): return [] return [NumberField(f, var, check=False) for f in self.root[s]] def ramified_at(self, S, d=None, var='a'): """ Return all fields in the database of degree d ramified exactly at the primes in S. The fields are ordered by degree and discriminant. INPUT: - ``S`` - list or set of primes - ``d`` - None (default, in which case all fields of degree <= 6 are returned) or a positive integer giving the degree of the number fields returned. - ``var`` - the name used for the generator of the number fields (default 'a'). EXAMPLES:: sage: J = JonesDatabase() # optional - jones_database sage: J.ramified_at([101,109]) # optional - jones_database [] sage: J.ramified_at([109]) # optional - jones_database [Number Field in a with defining polynomial x^2 - 109, Number Field in a with defining polynomial x^3 - x^2 - 36*x + 4, Number Field in a with defining polynomial x^4 - x^3 + 14*x^2 + 34*x + 393] sage: J.ramified_at(101) # optional - jones_database [Number Field in a with defining polynomial x^2 - 101, Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361, Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6, Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4, Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17] sage: J.ramified_at((2, 5, 29), 3, 'c') # optional - jones_database [Number Field in c with defining polynomial x^3 - x^2 - 8*x - 28, Number Field in c with defining polynomial x^3 - x^2 + 10*x + 102, Number Field in c with defining polynomial x^3 - x^2 + 97*x - 333, Number Field in c with defining polynomial x^3 - x^2 - 48*x - 188] """ Z = self.get(S, var=var) if d == None: Z = [(k.degree(), k.discriminant().abs(), k.discriminant() > 0, k) for k in Z] else: Z = [(k.discriminant().abs(), k.discriminant() > 0, k) for k in Z if k.degree() == d] Z.sort() return [z[-1] for z in Z]
Finite Fields
One can get a finite field with p-power elements.
Elliptic Curves
File: /home/iwao/sage-4.5.3-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_rational_field.py
Type: <type ‘instancemethod’>
Definition: E.analytic_rank(algorithm=’cremona’)
Docstring:
Return an integer that is probably the analytic rank of this elliptic curve.
INPUT:
- algorithm -
- ‘cremona’ (default) - Use the Buhler-Gross algorithm as implemented in GP by Tom Womack and John Cremona, who note that their implementation is practical for any rank and conductor \leq 10^{10} in 10 minutes.
- ‘sympow’ -use Watkins’s program sympow
- ‘rubinstein’ - use Rubinstein’s L-function C++ program lcalc.
- ‘magma’ - use MAGMA
- ‘all’ - compute with all other free algorithms, check that the answers agree, and return the common answer.
Note
If the curve is loaded from the large Cremona database, then the modular degree is taken from the database.
Of the three above, probably Rubinstein’s is the most efficient (in some limited testing I’ve done).
Note
It is an open problem to prove that any particular elliptic curve has analytic rank \geq 4.
EXAMPLES:
sage: E = EllipticCurve('389a') sage: E.analytic_rank(algorithm='cremona') 2 sage: E.analytic_rank(algorithm='rubinstein') 2 sage: E.analytic_rank(algorithm='sympow') 2 sage: E.analytic_rank(algorithm='magma') # optional - magma 2 sage: E.analytic_rank(algorithm='all') 2TESTS:
When the input is horrendous, some of the algorithms just bomb out with a RuntimeError:
sage: EllipticCurve([1234567,89101112]).analytic_rank(algorithm='rubinstein') ... RuntimeError: unable to compute analytic rank using rubinstein algorithm ('unable to convert x (= 6.19283e+19 and is too large) to an integer') sage: EllipticCurve([1234567,89101112]).analytic_rank(algorithm='sympow') ... RuntimeError: failed to compute analytic rank
One can give an elliptic curves by its label.
Invoke mwrank from Sage.
Prof. H. Nakamura (Okayama U.) asked me how to compute the rational points of
the elliptic curve by mwrank. If it has non-trivial rational point, then is a congruent number.
The answer is...
The curve comes from "congruent number problem". 2012 is a congruent
number, and the right triangle associate with it is given by , and below.
Let draw the triangle!
Please note that the and axises. The true form of this right triangle is...
S. Stein (Sage project leader) described the congruent number problem, Elliptic curves and Sage. See
http://modular.math.washington.edu/simuw06/
The author (I. K.) thanks Mr. S. Yokoyama (Kyushu) for bringing this documents to his attention.
Cremona's table
Install extra package:
install_package('database_cremona_ellcurve-20071019.p0')
Elliptic Curves over real quadratic fields
Mr. S. Yokoyama (Kyushu) asked me how to find a point on a curve
, where is the fundamental unit of a real quadratic for
some specific .
D. Simon's algebraic descent code (written in pari-gp) is included in Sage.
Modular Forms
Sage has huge amount of functions related to elliptic curves, modular forms of one variables and modular abelian varieties.
For those who interested in these features, the author recommend to read the section of Sage tutorial
http://sagemath.org/doc/tutorial/tour_advanced.html#elliptic-curves and W. Stein's book "
Modular Forms, a Computational Approach (Graduate Studies in Mathematics)", AMS 2007.
Misc: LaTeX output, File I/O
Miscellaneous topics. The cell which begin with %latex is rendered by LaTeX.
One can store Sage objects into files and restore them.
Store the results of computation into a file.
Load stored computation and compare it with original one.
Thats's all!
Thank you for your attention.
The list of Sage's extra-packages. These are not installed by default but can be installed by
install_package() command.