Demo -- 20071031 system:sage {{{id=0| version() /// 'SAGE Version 2.8.10, Release Date: 2007-10-28' }}} {{{id=86| os.uname() /// ('Darwin', 'D-69-91-159-194.dhcp4.washington.edu', '9.0.0', 'Darwin Kernel Version 9.0.0: Tue Oct 9 21:35:55 PDT 2007; root:xnu-1228~1/RELEASE_I386', 'i386') }}} {{{id=87| }}} {{{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)^2 - (4 + 6*i)^2 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=106| type(F) /// }}} {{{id=108| F[0] /// (Fractional ideal (1/2*a^2 - 1/2*a + 1), 1) }}} {{{id=114| type(F[0]) /// }}} {{{id=112| F[0][0] /// Fractional ideal (1/2*a^2 - 1/2*a + 1) }}} {{{id=115| F[0][1] /// 1 }}} {{{id=107| list(F) /// [(Fractional ideal (1/2*a^2 - 1/2*a + 1), 1), (Fractional ideal (a^2 - 2*a + 3), 1), (Fractional ideal (3/2*a^2 - 5/2*a + 4), 1)] }}} {{{id=113| }}} {{{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]^10; M /// Fractional ideal (-51*a^2 - 238*a - 255) }}} {{{id=6| M.factor() /// (Fractional ideal (a^2 + 11*a + 23)) * (Fractional ideal (-5*a^2 + 9*a - 15)) * (Fractional ideal (a^2 - 2*a + 3))^10 }}} {{{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=118| proof.all(True) }}} {{{id=117| time next_prime(10^100) /// 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000267 CPU time: 0.32 s, Wall time: 0.32 s }}} {{{id=48| p = next_prime(10^24); q = next_prime(10^26); D = p*q; D /// 100000000000000000000000767000000000000000000000469 }}} {{{id=88| # That this next command is slow will be fixed by # Robert Bradshaw soon-ish. }}} {{{id=47| time K. = NumberField(x^2 - D, check=False) /// CPU time: 2.33 s, Wall time: 2.67 s }}} {{{id=116| time for _ in xrange(10^5): c = b*b /// CPU time: 0.21 s, Wall time: 0.21 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=119| time K.maximal_order(17).basis() /// [1, b] CPU time: 0.01 s, Wall time: 0.01 s }}} {{{id=120| time K.maximal_order(2).basis() /// [1/2*b + 1/2, 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.32 s, Wall time: 2.63 s }}} {{{id=50| time factor(D) /// 1000000000000000000000007 * 100000000000000000000000067 CPU time: 2.35 s, Wall time: 2.65 s }}} {{{id=46| }}} {{{id=10| }}}

Construction of General Orders

{{{id=121| QQ[2^(1/3)] /// Number Field in a with defining polynomial x^3 - 2 }}} {{{id=122| L = QQ[sqrt(2), 2^(1/3)] }}} {{{id=123| sqrt2, a = L.gens() }}} {{{id=124| (sqrt2 + a)^3 /// (3*a^2 + 2)*sqrt2 + 6*a + 2 }}} {{{id=55| K. = NumberField(x^3 - 2); K /// Number Field in c with defining polynomial x^3 - 2 }}} {{{id=54| c^3 /// 2 }}} {{{id=125| S = K.order([2*c]); S.basis() /// [1, 2*c, 4*c^2] }}} {{{id=53| R = K.order([2*c, 6*c^2]); R /// Order in Number Field in c with defining polynomial x^3 - 2 }}} {{{id=12| R.basis() /// [1, 2*c, 2*c^2] }}} {{{id=126| S.index_in(R) /// 2 }}} {{{id=127| R.index_in(S) /// 1/2 }}} {{{id=129| R.ring_generators() /// [2*c, 2*c^2] }}} {{{id=130| S.ring_generators() /// [2*c] }}} {{{id=131| R.basis() /// [1, 2*c, 2*c^2] }}} {{{id=58| factor( R.discriminant() ) /// -1 * 2^6 * 3^3 }}} {{{id=57| factor( K.discriminant() ) /// -1 * 2^2 * 3^3 }}} {{{id=132| R.is_maximal() /// False }}} {{{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| }}}

Real and Complex Embeddings

{{{id=133| QQ[sqrt(5)] /// Number Field in sqrt5 with defining polynomial x^2 - 5 }}} {{{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| # This actually crashes in 2.8.10, but is fixed in 2.8.11 n = 17 z = [sig(i*B[0] + j*B[1]) for i in [-n..n] for j in [-n..n]] }}} {{{id=18| show(points(z, pointsize=30), xmax=7, ymax=7, xmin=-7,ymin=-7) }}} {{{id=93| }}} {{{id=92| # Next consider a totally real cubic field K. = NumberField(x^3 - 4*x - 2) }}} {{{id=141| var('x, a, b') show(solve(x^5 + a*x + b == 0, x)[0]) ///
0 = {x}^{5} + {a \cdot x} + b
}}} {{{id=139| g = K.defining_polynomial() }}} {{{id=140| (g^2).real_root_intervals() /// [((-27/16, -51/32), 2), ((-3/4, -3/8), 2), ((3/2, 9/4), 2)] }}} {{{id=135| R. = RealField(300)[] }}} {{{id=136| f = x^3 - 4*x - 2 }}} {{{id=137| f.roots() /// [(-1.67513087056664607088962179815006048080803252767737273261215386984144204299049931974220610, 1), (-0.539188872810889116525875902698520008099887109542126701719228446667686003442766955053765150, 1), (2.21431974337753518741549770084858048890791963721949943433138231650912804643326627479597125, 1)] }}} {{{id=96| show(solve(x^3 - 4*x - 2 == 0, x)[0]) ///
x = {\left( \frac{{-\sqrt{ 3 } \cdot i}}{2} - \frac{1}{2} \right) \cdot \left( {\left( \frac{{\sqrt{ 37 } \cdot i}}{{3 \cdot \sqrt{ 3 }}} + 1 \right)}^{\frac{1}{3}} \right)} + \frac{{4 \cdot \left( \frac{{\sqrt{ 3 } \cdot i}}{2} - \frac{1}{2} \right)}}{{3 \cdot \left( {\left( \frac{{\sqrt{ 37 } \cdot i}}{{3 \cdot \sqrt{ 3 }}} + 1 \right)}^{\frac{1}{3}} \right)}}
}}} {{{id=95| sigma = K.real_embeddings(); sigma /// [Ring morphism: From: Number Field in b with defining polynomial x^3 - 4*x - 2 To: Real Double Field Defn: b |--> -1.67513087057, Ring morphism: From: Number Field in b with defining polynomial x^3 - 4*x - 2 To: Real Double Field Defn: b |--> -0.539188872811, Ring morphism: From: Number Field in b with defining polynomial x^3 - 4*x - 2 To: Real Double Field Defn: b |--> 2.21431974338] }}} {{{id=94| # 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), sigma[2](z)) }}} {{{id=91| # Plot a bunch of points in the ring of integers. B = K.maximal_order().basis(); B /// [1, b, b^2] }}} {{{id=90| %time n = 4 z = [sig(i*B[0] + j*B[1] + k*B[2]) for i in [-n..n] \ for j in [-n..n] for k in [-n..n]] /// CPU time: 4.33 s, Wall time: 4.34 s }}} {{{id=100| t = Tachyon(xres=600, yres=400, camera_center=(20,20,20), look_at=(10,0,0), raydepth=4) t.light((10,3,2), 1, (1,1,1)) t.light((10,-3,2), 1, (1,1,1)) t.texture('bg', ambient=1, diffuse=1, specular=0, opacity=1.0, color=(1,1,1)) t.plane((-1.6,-1.6,-1.6), (1.6,1.6,1.6), 'bg') t.texture('red', color=(0,0,1)) for w in z: t.sphere(w, 0.1, 'red') t.show() }}} {{{id=89| P = point3d(z, size=1) }}} {{{id=98| P.show() }}} {{{id=103| from sage.plot.plot3d.shapes import * S = Sphere(.1, color='blue') A = S for w in z: A += S.translate(w[0], w[1], w[2]) A.scale(0.3).show() }}} {{{id=102| }}} {{{id=97| }}} {{{id=19| P.show }}}

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| norm(I*J) /// 1445 }}} {{{id=142| 5*289 /// 1445 }}} {{{id=83| Z =I/J; Z /// Fractional ideal (-1/17*a) }}} {{{id=82| norm(Z) /// 5/289 }}} {{{id=144| }}} {{{id=143| }}} {{{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=104| }}} {{{id=105| # compute some class numbers }}} {{{id=23| %time for d in [2..10000]: if is_fundamental_discriminant(d): h = QuadraticField(d, 'a').class_number() if h == 1: print d, print /// 5 8 12 13 17 21 24 28 29 33 37 41 44 53 56 57 61 69 73 76 77 88 89 92 93 97 101 109 113 124 129 133 137 141 149 152 157 161 172 173 177 181 184 188 193 197 201 209 213 217 233 236 237 241 248 249 253 268 269 277 281 284 293 301 309 313 317 329 332 337 341 344 349 353 373 376 381 389 393 397 409 412 413 417 421 428 433 437 449 453 457 461 472 489 497 501 508 509 517 521 524 536 537 541 553 556 557 569 573 581 589 593 597 601 604 613 617 632 633 641 649 652 653 661 664 668 669 673 677 681 701 709 713 716 717 721 737 749 753 757 764 769 773 781 789 796 797 809 813 821 824 829 844 849 853 856 857 869 877 881 889 893 908 913 917 921 929 933 937 941 953 956 973 977 989 997 1004 1013 1021 1033 1041 1048 1049 1052 1057 1061 1069 1077 1081 1084 1097 1109 1112 1117 1121 1132 1133 1137 1141 1149 1153 1169 1177 1181 1193 1201 1208 1213 1217 1228 1237 1244 1249 1253 1273 1277 1289 1293 1301 1317 1321 1324 1329 1333 1336 1337 1349 1357 1361 1381 1388 1389 1397 1401 1409 1432 1433 1437 1441 1453 1457 1461 1468 1473 1477 1481 1493 1497 1501 1516 1528 1529 1532 1541 1549 1553 1561 1569 1577 1589 1592 1597 1609 1613 1621 1633 1637 1657 1661 1669 1673 1676 1688 1689 1693 1697 1709 1713 1721 1724 1733 1741 1753 1757 1777 1784 1789 1793 1797 1801 1816 1817 1821 1829 1837 1841 1852 1857 1861 1868 1873 1877 1889 1893 1909 1912 1913 1916 1933 1941 1948 1949 1964 1969 1973 1977 1981 1993 1997 2008 2012 2017 2033 2049 2053 2069 2073 2077 2092 2104 2113 2129 2137 2141 2149 2157 2161 2168 2181 2188 2189 2201 2217 2221 2229 2237 2252 2253 2264 2269 2273 2281 2284 2293 2297 2309 2317 2321 2333 2341 2348 2357 2361 2369 2377 2381 2389 2393 2396 2413 2417 2428 2433 2437 2441 2449 2453 2456 2461 2469 2473 2476 2477 2481 2488 2489 2497 2513 2517 2521 2524 2537 2549 2569 2572 2573 2577 2588 2593 2609 2617 2621 2629 2633 2641 2648 2649 2653 2657 2661 2681 2689 2693 2721 2729 2732 2733 2741 2749 2753 2757 2761 2764 2773 2776 2789 2797 2801 2833 2837 2841 2861 2869 2872 2876 2881 2893 2897 2901 2909 2921 2933 2936 2949 2953 2956 2957 2969 2972 2973 3001 3004 3013 3017 3032 3037 3041 3049 3053 3057 3061 3064 3073 3089 3093 3097 3101 3109 3113 3117 3148 3149 3153 3169 3189 3193 3197 3209 3217 3241 3244 3257 3269 3273 3292 3301 3308 3309 3313 3317 3329 3337 3352 3353 3361 3369 3373 3377 3389 3397 3401 3409 3413 3421 3433 3436 3437 3448 3449 3452 3453 3457 3461 3469 3473 3489 3493 3512 3513 3517 3521 3529 3532 3533 3541 3544 3548 3557 3561 3581 3593 3613 3617 3628 3629 3637 3641 3644 3661 3669 3673 3676 3677 3693 3697 3701 3704 3709 3713 3733 3749 3761 3769 3777 3781 3788 3793 3797 3817 3821 3829 3832 3833 3837 3841 3849 3853 3868 3881 3884 3896 3901 3909 3917 3921 3929 3932 3937 3949 3953 3964 3989 3992 4013 4021 4024 4037 4049 4057 4061 4073 4076 4093 4101 4109 4117 4124 4129 4133 4153 4156 4157 4169 4177 4184 4189 4197 4201 4204 4213 4217 4237 4241 4249 4252 4253 4261 4269 4273 4289 4297 4309 4313 4317 4333 4337 4341 4349 4373 4376 4377 4393 4397 4412 4413 4417 4421 4429 4449 4457 4461 4492 4497 4501 4513 4517 4529 4533 4541 4549 4561 4568 4569 4577 4593 4601 4604 4609 4613 4621 4629 4637 4652 4657 4661 4673 4677 4681 4696 4701 4713 4721 4733 4737 4741 4748 4769 4781 4789 4792 4793 4801 4813 4817 4821 4829 4837 4856 4861 4873 4877 4881 4897 4909 4924 4937 4952 4957 4969 4973 4989 4993 4997 5001 5009 5021 5029 5033 5036 5048 5053 5077 5093 5097 5101 5113 5116 5129 5132 5137 5144 5149 5153 5164 5169 5173 5177 5189 5197 5201 5209 5212 5221 5228 5233 5237 5257 5272 5276 5277 5293 5309 5349 5357 5361 5377 5381 5393 5401 5413 5433 5437 5441 5449 5461 5464 5469 5489 5493 5501 5509 5528 5533 5541 5549 5557 5561 5569 5573 5581 5596 5601 5609 5633 5641 5653 5657 5669 5677 5689 5692 5693 5701 5708 5717 5721 5737 5749 5752 5753 5756 5761 5773 5788 5789 5793 5801 5804 5813 5816 5833 5836 5849 5857 5861 5869 5873 5881 5884 5893 5897 5909 5921 5932 5937 5948 5953 5961 5969 5977 5981 5996 5997 6008 6009 6013 6017 6029 6033 6037 6041 6044 6049 6073 6077 6089 6101 6117 6121 6124 6169 6172 6173 6181 6189 6193 6197 6217 6221 6229 6233 6236 6249 6257 6261 6269 6277 6281 6284 6296 6297 6301 6313 6316 6317 6329 6332 6333 6337 6349 6353 6361 6373 6377 6389 6393 6397 6421 6428 6429 6433 6449 6457 6469 6473 6476 6488 6493 6509 6521 6529 6533 6537 6541 6553 6569 6577 6581 6589 6593 6609 6621 6629 6652 6653 6661 6668 6673 6677 6689 6701 6709 6712 6717 6729 6733 6737 6753 6761 6769 6781 6793 6796 6797 6801 6821 6829 6833 6841 6857 6861 6869 6872 6881 6892 6904 6913 6917 6933 6937 6941 6961 6973 6977 6988 7001 7009 7013 7017 7036 7037 7041 7061 7069 7073 7096 7097 7109 7113 7121 7129 7132 7133 7149 7153 7169 7177 7181 7193 7197 7201 7213 7217 7233 7237 7253 7256 7269 7277 7288 7292 7297 7309 7313 7321 7324 7333 7341 7349 7352 7357 7369 7377 7393 7401 7409 7417 7433 7457 7468 7477 7484 7489 7493 7509 7516 7517 7529 7541 7549 7561 7576 7577 7589 7593 7597 7609 7613 7617 7621 7629 7637 7649 7653 7661 7669 7681 7697 7717 7724 7729 7737 7741 7757 7768 7773 7781 7789 7793 7804 7829 7841 7849 7853 7864 7877 7901 7909 7916 7928 7933 7937 7941 7949 7961 7977 7981 7989 7993 7996 7997 8009 8012 8013 8044 8053 8061 8081 8089 8093 8117 8129 8133 8137 8141 8152 8153 8156 8157 8161 8189 8193 8197 8201 8209 8213 8221 8233 8237 8248 8252 8257 8261 8269 8273 8293 8297 8301 8312 8317 8329 8332 8341 8348 8353 8369 8377 8389 8401 8408 8409 8413 8417 8429 8444 8453 8457 8461 8504 8509 8513 8521 8524 8529 8537 8549 8553 8557 8561 8573 8609 8617 8629 8641 8657 8669 8677 8681 8693 8696 8709 8716 8717 8728 8737 8741 8753 8777 8781 8797 8809 8812 8813 8817 8821 8824 8849 8861 8873 8881 8889 8893 8913 8921 8929 8933 8941 8953 8956 8969 8972 8977 8981 8984 8997 9001 9013 9017 9033 9037 9041 9053 9057 9068 9069 9097 9109 9121 9137 9148 9157 9161 9173 9201 9209 9221 9233 9237 9241 9244 9249 9253 9257 9277 9304 9313 9329 9337 9341 9349 9353 9356 9357 9368 9377 9388 9397 9404 9421 9433 9437 9449 9461 9473 9481 9484 9489 9493 9496 9497 9501 9521 9532 9533 9557 9561 9569 9573 9589 9601 9609 9613 9617 9629 9637 9641 9644 9649 9661 9677 9689 9692 9697 9713 9721 9733 9753 9761 9769 9777 9781 9784 9788 9793 9817 9848 9853 9857 9901 9913 9917 9921 9929 9941 9949 9957 9961 9969 9973 9977 9989 9993 CPU time: 12.03 s, Wall time: 12.12 s }}} {{{id=27| %time for d in [-1,-2..-10000]: if is_fundamental_discriminant(d): h = QuadraticField(d, 'a').class_number() if h == 1: print d, print /// -3 -4 -7 -8 -11 -19 -43 -67 -163 CPU time: 10.23 s, Wall time: 10.24 s }}} {{{id=81| QuadraticField(-2007,'a').class_number() /// 7 }}} {{{id=145| K /// Number Field in a with defining polynomial x^2 + 23 }}} {{{id=146| z = K.zeta_function(1000) }}} {{{id=147| z(-1/2) /// -0.617912851515018974201162892142590466817714928254718615590587934533905679974360508160292436517220747077887378343063571617574136858268158327444017093850764541113386631584593082526744375573096441673698819549155502935006633256178514108420814489520849082067444078508291760433982262018464774039266100389012 }}} {{{id=148| z.taylor_series(-1, 10) /// -1.02642081822527 - 0.527115227131624*z + 0.352846307523807*z^2 - 0.255614620135300*z^3 - 0.0421524700662994*z^4 + 0.0328336345811623*z^5 - 0.0321461807285247*z^6 + 0.00190003651578682*z^7 - 0.00177398808970365*z^8 - 0.00161849027098422*z^9 + O(z^10) }}} {{{id=149| }}}