Algebraic Number Theory 10/10/2012

go to uw.sagenb.org

Basics

You can click evaluate or press [shift]+[enter]

{{{id=129| /// }}} {{{id=125| 2+2 /// 4 }}} {{{id=5| 2*2 /// 4 }}}

If you are familiar with Python, Sage does a bit of preparsing to make the syntaxed more "math friendly".  

So 2^4 does mean $2^4$.

{{{id=6| 2^3 /// 8 }}} {{{id=126| 2*(4-5)^5-3 /// -5 }}}

x is predefined to be a variable

{{{id=7| x^2 /// x^2 }}} {{{id=127| y /// y }}} {{{id=9| y = var('y') /// }}} {{{id=10| x+y /// x + y }}}

Even though x is a predefined variable, you can assign objects to it.  

But then it's no longer a variable, so be careful.

{{{id=11| x = 2 /// }}} {{{id=12| x+y /// y + 2 }}} {{{id=13| x = var('x') /// }}} {{{id=14| x+y /// x + y }}} {{{id=15| f = x^3+x-2 /// }}} {{{id=130| f /// x^3 + x - 2 }}} {{{id=16| f(x=2) /// 8 }}} {{{id=131| x /// x }}} {{{id=17| g = x*y+y /// }}} {{{id=18| g(y=3) /// 3*x + 3 }}} {{{id=132| plot(f,(-10,10),color = 'purple') /// }}} {{{id=115| plot(f,(-5,5),color = 'green')+plot(g(y=3),(-5,5),color = 'red') /// }}}

Lists, loops, and Indexing

Python indeces start at 0!  (Not 1!)

{{{id=109| l = [i for i in range(10)] l /// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] }}} {{{id=116| len(l) /// 10 }}} {{{id=111| for i in range(10,15): print i /// 10 11 12 13 14 }}} {{{id=134| fac = [(next_prime(10^i)+1).factor() for i in range(10,15)] /// }}} {{{id=112| for i in l: if i%2 == 0: print i else: print 'not even' /// 0 not even 2 not even 4 not even 6 not even 8 not even }}} {{{id=117| m = [i for i in range(10,14)] print m /// [10, 11, 12, 13] }}} {{{id=118| m = [i for i in range(1,15)] /// }}} {{{id=119| m[0], m[-1] /// (1, 14) }}} {{{id=120| m[1],m[-2] /// (2, 13) }}}

Matrices

{{{id=19| A = matrix([[-1,2,3],[2,1,3],[3,0,0]]); A /// [-1 2 3] [ 2 1 3] [ 3 0 0] }}} {{{id=136| latex(A) /// \left(\begin{array}{rrr} -1 & 2 & 3 \\ 2 & 1 & 3 \\ 3 & 0 & 0 \end{array}\right) }}} {{{id=21| A.echelon_form() /// [1 0 6] [0 1 0] [0 0 9] }}} {{{id=22| A.base_ring() /// Integer Ring }}} {{{id=23| B = matrix(QQ,[[-1,2,3],[2,1,3],[3,0,0]]) /// }}} {{{id=24| B.echelon_form() /// [1 0 0] [0 1 0] [0 0 1] }}} {{{id=137| A.change_ring(QQ).echelon_form() /// [1 0 0] [0 1 0] [0 0 1] }}} {{{id=25| B.base_ring() /// Rational Field }}} {{{id=26| S, U, V = A.smith_form() /// }}} {{{id=27| S, U, V /// ( [1 0 0] [ 0 1 0] [ 0 1 -3] [0 1 0] [ 1 -2 0] [ 1 4 -9] [0 0 9], [ 3 -6 -1], [ 0 -2 5] ) }}} {{{id=138| U*A*V == S /// True }}} {{{id=139| A.base_ring() /// Integer Ring }}} {{{id=28| A,B /// ( [-1 2 3] [-1 2 3] [ 2 1 3] [ 2 1 3] [ 3 0 0], [ 3 0 0] ) }}} {{{id=140| B.base_ring() /// Rational Field }}} {{{id=29| C = A.change_ring(RR); C /// [-1.00000000000000 2.00000000000000 3.00000000000000] [ 2.00000000000000 1.00000000000000 3.00000000000000] [ 3.00000000000000 0.000000000000000 0.000000000000000] }}} {{{id=141| C.change_ring(ZZ) /// [-1 2 3] [ 2 1 3] [ 3 0 0] }}} {{{id=121| M = identity_matrix(5); M /// [1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1] }}} {{{id=122| N = zero_matrix(5,5); N /// [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] }}}

Useful things:

tab completion

?

??

search_src('stuff to look for')

{{{id=142| /// }}} {{{id=123| search_src('number field') /// }}}

Fields, Rings and Ideals

Number Fields

Basic examples, $\mathbb{Z}$ and $\mathbb{Q}$

{{{id=143| QQ.zero_element() /// 0 }}} {{{id=144| QQbar.ideal(7) /// Principal ideal (1) of Algebraic Field }}} {{{id=30| ZZ.is_noetherian() /// True }}} {{{id=99| /// }}} {{{id=40| I = ZZ.ideal(18) J = ZZ.ideal(5) I,J,I+J /// (Principal ideal (18) of Integer Ring, Principal ideal (5) of Integer Ring, Principal ideal (1) of Integer Ring) }}} {{{id=37| I.gens(),J.gens(), (I+J).gens() /// ((18,), (5,), (1,)) }}}

Everyone's favorite number field:

{{{id=39| x = var('x') F. = NumberField(x^2-x-1) print F OF = F.ring_of_integers() OF.gens() /// Number Field in a with defining polynomial x^2 - x - 1 [1, a] }}} {{{id=149| OF.basis() /// [1, a] }}} {{{id=150| F.gens() /// (a,) }}} {{{id=45| a in OF /// True }}} {{{id=46| a+2 in OF /// True }}} {{{id=47| a/2 in OF /// False }}} {{{id=151| a/2 in F /// True }}} {{{id=48| (a+2).minpoly() /// x^2 - 5*x + 5 }}}

Can create and work with ideals as before.

{{{id=54| I = F.ideal(5) print I print I.factor() /// Fractional ideal (5) (Fractional ideal (-2*a + 1))^2 }}} {{{id=55| J = F.ideal(5).factor()[0][0]; J /// Fractional ideal (-2*a + 1) }}} {{{id=152| F.ideal(5).factor()[0] /// (Fractional ideal (-2*a + 1), 2) }}} {{{id=56| F.ideal((7-21*a)*5*(3*a+13)).factor() /// (Fractional ideal (-3*a + 1)) * (Fractional ideal (3*a + 13)) * (Fractional ideal (-2*a + 1))^2 * (Fractional ideal (7)) }}} {{{id=49| K. = QuadraticField(-5) /// }}} {{{id=153| b.minpoly() /// x^2 + 5 }}} {{{id=50| F.class_number() /// 1 }}} {{{id=51| K.class_number() /// 2 }}} {{{id=52| K.ring_of_integers().gens() /// [1, b] }}} {{{id=53| b.is_integral() /// True }}} {{{id=58| L. = NumberField([x^2-2,x^2-x-1]) /// }}} {{{id=61| /// }}} {{{id=103| OL = L.ring_of_integers() /// }}} {{{id=105| O = L.order([1,a,b,a*b]) /// }}} {{{id=104| O == OL /// True }}} {{{id=154| OL.basis() /// [(b + 2)*a - 3*b, a - b, -2*b*a + b + 3, (3*b + 5)*a - 8*b - 1] }}} {{{id=106| alpha = a+3*b /// }}} {{{id=107| mList = [alpha*e for e in O.basis()] mList /// [(6*b + 3)*a - 7*b - 5, 2*b*a - 3*b - 1, (-5*b - 3)*a + 8*b + 3, (16*b + 8)*a - 21*b - 14] }}} {{{id=62| F.gen() /// a }}} {{{id=155| d = F.degree() bas = [F.gen()^i for i in range(d)] bas /// [1, a] }}} {{{id=156| M. = L.absolute_field() /// }}} {{{id=157| d = M.degree() bas = [M.gen()^i for i in range(d)] bas /// [1, c, c^2, c^3] }}} {{{id=160| elt = 1+c+3*c^3 /// }}} {{{id=161| elt.vector() /// (1, 1, 0, 3) }}} {{{id=162| /// }}} {{{id=158| mbas = M.ring_of_integers().basis() /// }}} {{{id=163| matrix([(elt*m).vector() for m in mbas]) /// [ 32/3 182/3 41 -70/3] [ 3 19 16 -6] [ -6 -33 -11 28] [ 28 162 107 -67] }}} {{{id=159| print L.gens() print M.gens() /// (a, b) (c,) }}} {{{id=63| e1,e2 = F.embeddings(CC) /// }}} {{{id=66| F.gens()[0],e1(F.gens()[0]),e2(F.gens()[0]) /// (a, -0.618033988749895, 1.61803398874989) }}} {{{id=64| c = a+b /// }}} {{{id=65| c.absolute_minpoly() /// x^4 - 2*x^3 - 5*x^2 + 6*x - 1 }}} {{{id=67| c.minpoly() /// x^2 - 2*b*x + b - 1 }}} {{{id=68| OL = L.ring_of_integers() OL.gens() /// [(b + 2)*a - 3*b, a - b, -2*b*a + b + 3, (3*b + 5)*a - 8*b - 1] }}} {{{id=69| kL = OL.residue_field(L.ideal(7).factor()[0][0]) /// }}} {{{id=70| kL.characteristic() /// 7 }}} {{{id=71| L.ideal(7).absolute_norm().factor() /// 7^4 }}} {{{id=72| O = L.order([1,a,b,a*b]) /// }}} {{{id=73| O.absolute_discriminant().factor() /// 2^6 * 5^2 }}} {{{id=74| OL.absolute_discriminant().factor() /// 2^6 * 5^2 }}} {{{id=76| O == OL /// True }}} {{{id=77| OL.basis() /// [(b + 2)*a - 3*b, a - b, -2*b*a + b + 3, (3*b + 5)*a - 8*b - 1] }}} {{{id=78| On = L.order([2,2*a,2*b,2*a*b]) /// }}} {{{id=79| On.absolute_discriminant().factor() /// 2^12 * 5^2 }}} {{{id=80| On.index_in(OL) /// 8 }}} {{{id=81| CyclotomicField(5) /// Cyclotomic Field of order 5 and degree 4 }}} {{{id=82| F.galois_group() /// Galois group of Number Field in a with defining polynomial x^2 - x - 1 }}} {{{id=83| LG = L.galois_closure('c') /// }}} {{{id=84| LG.absolute_discriminant() /// 1600 }}} {{{id=85| c.minpoly() /// x^2 - 2*b*x + b - 1 }}} {{{id=87| (a+b).minpoly() /// x^2 - 2*b*x + b - 1 }}}

Now a Function Fields Example

First, how one might nievely try.  It works, painfully.

{{{id=90| R. = QQ[] print R I = R.ideal([a^2-t, b^2-(t+1)]) print I.gens() /// Multivariate Polynomial Ring in a, b, t over Rational Field [a^2 - t, b^2 - t - 1] }}} {{{id=91| Q. = R.quotient(I); print Q S. = Q[] f = (x^2+1)^2 - 2*(t+1)*x^2 f /// Quotient of Multivariate Polynomial Ring in a, b, t over Rational Field by the ideal (a^2 - t, b^2 - t - 1) x^4 - 2*t*x^2 + 1 }}} {{{id=92| alpha = a+b; alpha basis = [1,a,b,a*b]; basis im = [b*alpha for b in basis]; im /// [a + b, a*b + t, a*b + t + 1, a*t + b*t + a] }}} {{{id=93| # I figured out this matrix by *looking* manually at im above. -- ugly...! mat = matrix(4,4,[[0,1,1,0], [t,0,0,1], [t+1,0,0,1],[0,t+1,t,0]]); print mat f = mat.charpoly(); f /// [ 0 1 1 0] [ t 0 0 1] [t + 1 0 0 1] [ 0 t + 1 t 0] x^4 + (-4*t - 2)*x^2 + 1 }}} {{{id=96| print alpha^4 print f(alpha) print (x^2+1)^2 - 2*(t+1)*x^2 /// 8*a*b*t + 4*a*b + 8*t^2 + 8*t + 1 0 x^4 - 2*t*x^2 + 1 }}}

Here's how to do this using function fields

{{{id=88| F. = FunctionField(QQ) K. = F[] R.
= F.extension(x^2-t) S. = R[] T. = R.extension(x^2-(t+1)) print T print (a+b).charpoly()*(-a+b).charpoly() # answer appears here. /// Function field in b defined by x^2 - t - 1 x^4 + (-4*t - 2)*x^2 + 1 }}} {{{id=98| /// }}} {{{id=133| search_src('contour plot') ///

Search Source Code: "contour plot"

  1. plot/contour_plot.py
  2. plot/graphics.py
  3. server/notebook/interact.py
}}} {{{id=145| (19).mod(13) /// 6 }}} {{{id=146| k = ZZ.residue_field(131) /// }}} {{{id=147| k.characteristic() /// 131 }}} {{{id=148| /// }}}