Ticket #11876: 11876.patch
File 11876.patch, 2.9 KB (added by , 11 years ago) 


sage/rings/number_field/number_field.py
# HG changeset patch # User Jeroen Demeyer <jdemeyer@cage.ugent.be> # Date 1317374710 7200 # Node ID 5a86889545f81f672faf2a89a19ae5480da1c03b # Parent e392b57cf0a7c2293641007d53a7d4a0904d7dc4 Store embedding when creating a subfield of a number field diff git a/sage/rings/number_field/number_field.py b/sage/rings/number_field/number_field.py
a b 1499 1499 To: Number Field in a with defining polynomial x^4  3 1500 1500 Defn: b > a^2 1501 1501 1502 ::1502 Subfields inherit embeddings:: 1503 1503 1504 1504 sage: K.<z> = CyclotomicField(5) 1505 sage: K.subfield(zz^2z^3+z^4) 1506 (Number Field in z0 with defining polynomial x^2  5, 1507 Ring morphism: 1508 From: Number Field in z0 with defining polynomial x^2  5 1509 To: Cyclotomic Field of order 5 and degree 4 1510 Defn: z0 > 2*z^3  2*z^2  1) 1505 sage: L, K_from_L = K.subfield(zz^2z^3+z^4) 1506 sage: L 1507 Number Field in z0 with defining polynomial x^2  5 1508 sage: CLF_from_K = K.coerce_embedding(); CLF_from_K 1509 Generic morphism: 1510 From: Cyclotomic Field of order 5 and degree 4 1511 To: Complex Lazy Field 1512 Defn: z > 0.309016994374948? + 0.951056516295154?*I 1513 sage: CLF_from_L = L.coerce_embedding(); CLF_from_L 1514 Generic morphism: 1515 From: Number Field in z0 with defining polynomial x^2  5 1516 To: Complex Lazy Field 1517 Defn: z0 > 2.23606797749979? + 0.?e14*I 1518 1519 Check transitivity:: 1520 1521 sage: CLF_from_L(L.gen()) 1522 2.23606797749979? + 0.?e14*I 1523 sage: CLF_from_K(K_from_L(L.gen())) 1524 2.23606797749979? + 0.?e14*I 1525 1526 If `self` has no specified embedding, then `K` comes with an 1527 embedding in `self`:: 1528 1529 sage: K.<a> = NumberField(x^6  6*x^4 + 8*x^2  1) 1530 sage: L.<b>, from_L = K.subfield(a^2) 1531 sage: L 1532 Number Field in b with defining polynomial x^3  6*x^2 + 8*x  1 1533 sage: L.gen_embedding() 1534 a^2 1511 1535 1512 1536 You can also view a number field as having a different generator by 1513 1537 just choosing the input to generate the whole field; for that it is … … 1520 1544 name = self.variable_name() + '0' 1521 1545 beta = self(alpha) 1522 1546 f = beta.minpoly() 1523 K = NumberField(f, names=name) 1547 # If self has a specified embedding, K should inherit it 1548 if self.coerce_embedding() is not None: 1549 emb = self.coerce_embedding()(beta) 1550 else: 1551 # Otherwise K should at least come with an embedding in self 1552 emb = beta 1553 K = NumberField(f, names=name, embedding=emb) 1524 1554 from_K = K.hom([beta]) 1525 1555 return K, from_K 1526 1556