Ticket #11876: 11876.patch

File 11876.patch, 2.9 KB (added by Jeroen Demeyer, 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  
    14991499              To:   Number Field in a with defining polynomial x^4 - 3
    15001500              Defn: b |--> a^2
    15011501       
    1502         ::
     1502        Subfields inherit embeddings::
    15031503       
    15041504            sage: K.<z> = CyclotomicField(5)
    1505             sage: K.subfield(z-z^2-z^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(z-z^2-z^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.?e-14*I
     1518       
     1519        Check transitivity::
     1520
     1521            sage: CLF_from_L(L.gen())
     1522            2.23606797749979? + 0.?e-14*I
     1523            sage: CLF_from_K(K_from_L(L.gen()))
     1524            2.23606797749979? + 0.?e-14*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
    15111535       
    15121536        You can also view a number field as having a different generator by
    15131537        just choosing the input to generate the whole field; for that it is
     
    15201544            name = self.variable_name() + '0'
    15211545        beta = self(alpha)
    15221546        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)
    15241554        from_K = K.hom([beta])
    15251555        return K, from_K
    15261556