Demo -- 20071031 system:sage {{{id=0| version() /// 'SAGE Version 2.8.9, Release Date: 2007-10-25' }}} {{{id=8| }}}

Ideal Congruence

{{{id=1| K. = NumberField(x^2 + 1) I = K.fractional_ideal(3 + 4*i) I /// Fractional ideal (4*i + 3) }}} {{{id=2| # Test to see if (1+2*i) and (4+6*i) are congruent modulo the ideal I: (1 + 2*i) - (4 + 6*i) in I /// True }}} {{{id=26| # They are. Test another congruence, where they aren't. (3 + 2*i) - (4 + 6*i) in I /// False }}} {{{id=29| # Test to see if (1+2*i) and (4+6*i) are congruent modulo the ideal I^2: (1 + 2*i) - (4 + 6*i) in I^2 /// False }}} {{{id=31| }}} {{{id=28| }}} {{{id=3| }}}

Fractional Ideal Factorization

{{{id=5| K. = NumberField(x^3 + x^2 - 2*x + 8); K /// Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8 }}} {{{id=32| I = K.fractional_ideal(2) }}} {{{id=33| F = I.factor(); F /// (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (a^2 - 2*a + 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4)) }}} {{{id=34| J = F[0][0]; J /// Fractional ideal (1/2*a^2 - 1/2*a + 1) }}} {{{id=36| J.is_prime() /// True }}} {{{id=38| J.residue_class_degree() /// 1 }}} {{{id=35| M = K.fractional_ideal(17) * F[1][0]^5; M /// Fractional ideal (-17*a^2 - 34*a + 51) }}} {{{id=6| M.factor()[0][0] /// Fractional ideal (a^2 + 11*a + 23) }}} {{{id=41| }}} {{{id=40| }}} {{{id=39| }}} {{{id=7| }}}

Computation of Rings of Integers

{{{id=43| K.
= NumberField(x^3 + x^2 - 2*x + 8); K /// Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8 }}} {{{id=42| R = K.maximal_order(); R /// Maximal Order in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8 }}} {{{id=9| R.basis() /// [1, 1/2*a^2 + 1/2*a, a^2] }}} {{{id=49| }}} {{{id=70| # Try a ring of integers where factoring is clearly the bottleneck. }}} {{{id=48| p = next_prime(10^24); q = next_prime(10^26); D = p*q; D /// 100000000000000000000000767000000000000000000000469 }}} {{{id=47| time K. = NumberField(x^2 - D) /// CPU time: 2.36 s, Wall time: 2.83 s }}} {{{id=44| # Computing just the p-maximal order is fast. time K.maximal_order(p).basis() /// [1, b] Time: CPU 0.01 s, Wall: 0.01 s }}} {{{id=45| time K.maximal_order(q).basis() /// [1, b] CPU time: 0.01 s, Wall time: 0.01 s }}} {{{id=51| time K.maximal_order().basis() /// [1/2*b + 1/2, b] CPU time: 2.37 s, Wall time: 2.85 s }}} {{{id=50| time factor(D) /// 1000000000000000000000007 * 100000000000000000000000067 CPU time: 2.36 s, Wall time: 2.87 s }}} {{{id=46| }}} {{{id=10| }}}

Construction of General Orders

{{{id=55| K. = NumberField(x^3 - 2); K /// Number Field in c with defining polynomial x^3 - 2 }}} {{{id=54| c^3 /// 2 }}} {{{id=53| R = K.order([2*c]); R /// Order in Number Field in c with defining polynomial x^3 - 2 }}} {{{id=12| R.basis() /// [1, 2*c, 4*c^2] }}} {{{id=58| factor( R.discriminant() ) /// -1 * 2^8 * 3^3 }}} {{{id=57| factor( K.discriminant() ) /// -1 * 2^2 * 3^3 }}} {{{id=60| R = K.order([13*c + 169*c^2]); R /// Order in Number Field in c with defining polynomial x^3 - 2 }}} {{{id=62| R.basis() /// [1, 169*c^2 + 13*c, 742417*c^2] }}} {{{id=63| n = R.index_in(K.order([2*c])); n /// 9651421/8 }}} {{{id=61| factor(n) /// 2^-3 * 13^3 * 23 * 191 }}} {{{id=65| }}} {{{id=64| }}} {{{id=13| }}}

Complex Embeddings

{{{id=67| K.
= NumberField(x^2 - 5) }}} {{{id=68| sigma = K.real_embeddings(); sigma /// [Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 To: Real Double Field Defn: a |--> -2.2360679775, Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 To: Real Double Field Defn: a |--> 2.2360679775] }}} {{{id=69| # Plot image of 1 and a under the map z |---> (sigma_0(z), sigma_1(z)) def sig(z): return (sigma[0](z), sigma[1](z)) show(points([sig(1), sig(a)], pointsize=30)) }}} {{{id=66| # Plot a bunch of points in the ring of integers. B = K.maximal_order().basis(); B /// [1/2*a + 1/2, a] }}} {{{id=72| # A bug!! :-( z = [sig(i*B[0] + j*B[1]) for i in [-3..3] for j in [-3..3]] # CRASH... /// Traceback (most recent call last): File "", line 1, in File "/home/was/books/ant/sage_notebook/worksheets/admin/5/code/53.py", line 7, in z = [sig(i*B[Integer(0)] + j*B[Integer(1)]) for i in (ellipsis_range(-Integer(3),Ellipsis,Integer(3))) for j in (ellipsis_range(-Integer(3),Ellipsis,Integer(3)))] NameError: name 'sig' is not defined }}} {{{id=18| }}} {{{id=19| }}}

Ideal Norms

{{{id=75| K.
= NumberField(x^2 - 5) I = K.fractional_ideal(a) I.norm() /// 5 }}} {{{id=74| J = K.fractional_ideal(17) J.norm() /// 289 }}} {{{id=21| (I*J).norm() /// 1445 }}} {{{id=83| Z =I/J; Z /// Fractional ideal (-1/17*a) }}} {{{id=82| Z.norm() /// 5/289 }}} {{{id=85| }}} {{{id=84| }}} {{{id=22| }}}

Class Groups

{{{id=24| K.
= NumberField(x^2 + 23) }}} {{{id=76| C = K.class_group() }}} {{{id=77| C /// Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23 }}} {{{id=25| G = C.gens(); G /// [Fractional ideal class (2, 1/2*a - 1/2)] }}} {{{id=78| I = G[0]; I /// Fractional ideal class (2, 1/2*a - 1/2) }}} {{{id=79| I^2 /// Fractional ideal class (2, 1/2*a + 1/2) }}} {{{id=80| I^3 /// Trivial principal fractional ideal class }}} {{{id=81| }}}