CoCalc Public Fileswww / wiki / attachments / ant07(2f)plan(2f)2007(2d)10(2d)31 / demo.txtOpen in CoCalc with one click!
Author: William A. Stein
1
Demo -- 20071031
2
system:sage
3
4
{{{id=0|
5
version()
6
///
7
'SAGE Version 2.8.9, Release Date: 2007-10-25'
8
}}}
9
10
{{{id=8|
11
12
}}}
13
14
<h1> Ideal Congruence </h1>
15
16
{{{id=1|
17
K.<i> = NumberField(x^2 + 1)
18
I = K.fractional_ideal(3 + 4*i)
19
I
20
///
21
Fractional ideal (4*i + 3)
22
}}}
23
24
{{{id=2|
25
# Test to see if (1+2*i) and (4+6*i) are congruent modulo the ideal I:
26
(1 + 2*i) - (4 + 6*i) in I
27
///
28
True
29
}}}
30
31
{{{id=26|
32
# They are. Test another congruence, where they aren't.
33
(3 + 2*i) - (4 + 6*i) in I
34
///
35
False
36
}}}
37
38
{{{id=29|
39
# Test to see if (1+2*i) and (4+6*i) are congruent modulo the ideal I^2:
40
(1 + 2*i) - (4 + 6*i) in I^2
41
///
42
False
43
}}}
44
45
{{{id=31|
46
47
}}}
48
49
{{{id=28|
50
51
}}}
52
53
{{{id=3|
54
55
}}}
56
57
<h1> Fractional Ideal Factorization </h1>
58
59
{{{id=5|
60
K.<a> = NumberField(x^3 + x^2 - 2*x + 8); K
61
///
62
Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
63
}}}
64
65
{{{id=32|
66
I = K.fractional_ideal(2)
67
}}}
68
69
{{{id=33|
70
F = I.factor(); F
71
///
72
(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))
73
}}}
74
75
{{{id=34|
76
J = F[0][0]; J
77
///
78
Fractional ideal (1/2*a^2 - 1/2*a + 1)
79
}}}
80
81
{{{id=36|
82
J.is_prime()
83
///
84
True
85
}}}
86
87
{{{id=38|
88
J.residue_class_degree()
89
///
90
1
91
}}}
92
93
{{{id=35|
94
M = K.fractional_ideal(17) * F[1][0]^5; M
95
///
96
Fractional ideal (-17*a^2 - 34*a + 51)
97
}}}
98
99
{{{id=6|
100
M.factor()[0][0]
101
///
102
Fractional ideal (a^2 + 11*a + 23)
103
}}}
104
105
{{{id=41|
106
107
}}}
108
109
{{{id=40|
110
111
}}}
112
113
{{{id=39|
114
115
}}}
116
117
{{{id=7|
118
119
}}}
120
121
<h1> Computation of Rings of Integers</h1>
122
123
{{{id=43|
124
K.<a> = NumberField(x^3 + x^2 - 2*x + 8); K
125
///
126
Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
127
}}}
128
129
{{{id=42|
130
R = K.maximal_order(); R
131
///
132
Maximal Order in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
133
}}}
134
135
{{{id=9|
136
R.basis()
137
///
138
[1, 1/2*a^2 + 1/2*a, a^2]
139
}}}
140
141
{{{id=49|
142
143
}}}
144
145
{{{id=70|
146
# Try a ring of integers where factoring is clearly the bottleneck.
147
}}}
148
149
{{{id=48|
150
p = next_prime(10^24); q = next_prime(10^26); D = p*q; D
151
///
152
100000000000000000000000767000000000000000000000469
153
}}}
154
155
{{{id=47|
156
time K.<b> = NumberField(x^2 - D)
157
///
158
CPU time: 2.36 s, Wall time: 2.83 s
159
}}}
160
161
{{{id=44|
162
# Computing just the p-maximal order is fast.
163
time K.maximal_order(p).basis()
164
///
165
[1, b]
166
Time: CPU 0.01 s, Wall: 0.01 s
167
}}}
168
169
{{{id=45|
170
time K.maximal_order(q).basis()
171
///
172
[1, b]
173
CPU time: 0.01 s, Wall time: 0.01 s
174
}}}
175
176
{{{id=51|
177
time K.maximal_order().basis()
178
///
179
[1/2*b + 1/2, b]
180
CPU time: 2.37 s, Wall time: 2.85 s
181
}}}
182
183
{{{id=50|
184
time factor(D)
185
///
186
1000000000000000000000007 * 100000000000000000000000067
187
CPU time: 2.36 s, Wall time: 2.87 s
188
}}}
189
190
{{{id=46|
191
192
}}}
193
194
{{{id=10|
195
196
}}}
197
198
<h1> Construction of General Orders</h1>
199
200
{{{id=55|
201
K.<c> = NumberField(x^3 - 2); K
202
///
203
Number Field in c with defining polynomial x^3 - 2
204
}}}
205
206
{{{id=54|
207
c^3
208
///
209
2
210
}}}
211
212
{{{id=53|
213
R = K.order([2*c]); R
214
///
215
Order in Number Field in c with defining polynomial x^3 - 2
216
}}}
217
218
{{{id=12|
219
R.basis()
220
///
221
[1, 2*c, 4*c^2]
222
}}}
223
224
{{{id=58|
225
factor( R.discriminant() )
226
///
227
-1 * 2^8 * 3^3
228
}}}
229
230
{{{id=57|
231
factor( K.discriminant() )
232
///
233
-1 * 2^2 * 3^3
234
}}}
235
236
{{{id=60|
237
R = K.order([13*c + 169*c^2]); R
238
///
239
Order in Number Field in c with defining polynomial x^3 - 2
240
}}}
241
242
{{{id=62|
243
R.basis()
244
///
245
[1, 169*c^2 + 13*c, 742417*c^2]
246
}}}
247
248
{{{id=63|
249
n = R.index_in(K.order([2*c])); n
250
///
251
9651421/8
252
}}}
253
254
{{{id=61|
255
factor(n)
256
///
257
2^-3 * 13^3 * 23 * 191
258
}}}
259
260
{{{id=65|
261
262
}}}
263
264
{{{id=64|
265
266
}}}
267
268
{{{id=13|
269
270
}}}
271
272
<h1> Complex Embeddings </h1>
273
274
{{{id=67|
275
K.<a> = NumberField(x^2 - 5)
276
}}}
277
278
{{{id=68|
279
sigma = K.real_embeddings(); sigma
280
///
281
[Ring morphism:
282
From: Number Field in a with defining polynomial x^2 - 5
283
To: Real Double Field
284
Defn: a |--> -2.2360679775, Ring morphism:
285
From: Number Field in a with defining polynomial x^2 - 5
286
To: Real Double Field
287
Defn: a |--> 2.2360679775]
288
}}}
289
290
{{{id=69|
291
# Plot image of 1 and a under the map z |---> (sigma_0(z), sigma_1(z))
292
293
def sig(z):
294
return (sigma[0](z), sigma[1](z))
295
296
show(points([sig(1), sig(a)], pointsize=30))
297
}}}
298
299
{{{id=66|
300
# Plot a bunch of points in the ring of integers.
301
B = K.maximal_order().basis(); B
302
///
303
[1/2*a + 1/2, a]
304
}}}
305
306
{{{id=72|
307
# A bug!! :-(
308
z = [sig(i*B[0] + j*B[1]) for i in [-3..3] for j in [-3..3]]
309
310
# CRASH...
311
///
312
Traceback (most recent call last):
313
File "<stdin>", line 1, in <module>
314
File "/home/was/books/ant/sage_notebook/worksheets/admin/5/code/53.py", line 7, in <module>
315
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)))]
316
NameError: name 'sig' is not defined
317
}}}
318
319
{{{id=18|
320
321
}}}
322
323
{{{id=19|
324
325
}}}
326
327
<h1> Ideal Norms </h1>
328
329
{{{id=75|
330
K.<a> = NumberField(x^2 - 5)
331
I = K.fractional_ideal(a)
332
I.norm()
333
///
334
5
335
}}}
336
337
{{{id=74|
338
J = K.fractional_ideal(17)
339
J.norm()
340
///
341
289
342
}}}
343
344
{{{id=21|
345
(I*J).norm()
346
///
347
1445
348
}}}
349
350
{{{id=83|
351
Z =I/J; Z
352
///
353
Fractional ideal (-1/17*a)
354
}}}
355
356
{{{id=82|
357
Z.norm()
358
///
359
5/289
360
}}}
361
362
{{{id=85|
363
364
}}}
365
366
{{{id=84|
367
368
}}}
369
370
{{{id=22|
371
372
}}}
373
374
<h1> Class Groups </h1>
375
376
{{{id=24|
377
K.<a> = NumberField(x^2 + 23)
378
}}}
379
380
{{{id=76|
381
C = K.class_group()
382
}}}
383
384
{{{id=77|
385
C
386
///
387
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
388
}}}
389
390
{{{id=25|
391
G = C.gens(); G
392
///
393
[Fractional ideal class (2, 1/2*a - 1/2)]
394
}}}
395
396
{{{id=78|
397
I = G[0]; I
398
///
399
Fractional ideal class (2, 1/2*a - 1/2)
400
}}}
401
402
{{{id=79|
403
I^2
404
///
405
Fractional ideal class (2, 1/2*a + 1/2)
406
}}}
407
408
{{{id=80|
409
I^3
410
///
411
Trivial principal fractional ideal class
412
}}}
413
414
{{{id=81|
415
416
}}}
417