Ticket #9054: trac_9054_doctests-3.patch

File trac_9054_doctests-3.patch, 99.9 KB (added by saraedum, 6 years ago)

extended and unified doctests

  • doc/en/reference/index.rst

    exporting patch:
    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    Trac 9054: fixed and extended doctests. unified names of variables. added docs to reference manual
    
    diff --git a/doc/en/reference/index.rst b/doc/en/reference/index.rst
    index 4a6c001..2062afb 100644
    a b Enjoy Sage! 
    7171   rings_standard
    7272   rings_numerical
    7373   number_fields
     74   function_fields
    7475   padics
    7576   polynomial_rings
    7677   power_series
  • sage/categories/function_fields.py

    diff --git a/sage/categories/function_fields.py b/sage/categories/function_fields.py
    index 649c5e7..171a08a 100644
    a b  
    11r"""
    2 FunctionFields
     2Function fields
    33"""
    44#*****************************************************************************
    55#  Copyright (C) 2005      David Kohel <kohel@maths.usyd.edu>
  • sage/rings/function_field/constructor.py

    diff --git a/sage/rings/function_field/constructor.py b/sage/rings/function_field/constructor.py
    index b3664ed..51b1408 100644
    a b  
     1r"""
     2Factories to construct Function Fields.
     3
     4EXAMPLES::
     5
     6    sage: K.<x> = FunctionField(QQ); K
     7    Rational function field in x over Rational Field
     8    sage: L.<x> = FunctionField(QQ); L
     9    Rational function field in x over Rational Field
     10    sage: K is L
     11    True
     12"""
    113import function_field
    214from sage.misc.cachefunc import cached_function
    315from sage.misc.decorators import sage_wraps
  • sage/rings/function_field/function_field.py

    diff --git a/sage/rings/function_field/function_field.py b/sage/rings/function_field/function_field.py
    index 093dbd6..fe5371a 100644
    a b TESTS:: 
    4141    sage: TestSuite(K).run() #long time
    4242    sage: TestSuite(L).run() #long time
    4343    sage: TestSuite(M).run() #long time
    44     
    45 The following tow test suites do not pass '_test_elements' yet since
    46 R.an_element() has a _test_category method wich it should not have.
     44 
     45The following two test suites do not pass ``_test_elements`` yet since
     46``R.an_element()`` has a ``_test_category`` method wich it should not have.
    4747It is not the fault of the function field code so this will
    48 be fixed in another ticket.
     48be fixed in another ticket::
     49
    4950    sage: TestSuite(R).run(skip = '_test_elements') #long time
    5051    sage: TestSuite(S).run(skip = '_test_elements') #long time
    51 
    52    
    5352"""
    5453
    5554from sage.structure.category_object import CategoryObject
    import maps 
    6968
    7069def is_FunctionField(x):
    7170    """
    72     Return True if x is of function field type.
     71    Return True if ``x`` is of function field type.
    7372
    7473    EXAMPLES::
    7574   
    class FunctionField(Field): 
    9493        True
    9594    """
    9695    def some_elements(self):
    97          #the number of ellements could be made bigger late rbut right now the
    98          #TestSuite(F).run() take to long with more elements.
    99          return (self.random_element() for i in xrange(3))
     96         """
     97         Return a list of elements in the function field.
     98
     99         EXAMPLES::
     100
     101            sage: K.<x> = FunctionField(QQ)
     102            sage: elements = K.some_elements()
     103            sage: elements # random output
     104            [(x - 3/2)/(x^2 - 12/5*x + 1/18)]
     105            sage: False in [e in K for e in elements]
     106            False
     107         """
     108         return [self.random_element()]
    100109
    101110    def characteristic(self):
    102111        """
    class FunctionField(Field): 
    109118            0
    110119            sage: R.<t> = FunctionField(GF(7))
    111120            sage: R.characteristic()
    112             7       
     121            7
    113122        """
    114123        return self.constant_field().characteristic()
    115124   
    class FunctionField(Field): 
    136145
    137146        INPUT:
    138147       
    139             - `f` -- a univariate polynomial over self
     148            - ``f`` -- a univariate polynomial over self
    140149            - ``names`` -- None or string or length-1 tuple
    141150
    142151        OUTPUT:
    class FunctionField(Field): 
    182191
    183192        EXAMPLES::
    184193
    185             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
    186             sage: O = L.order_with_basis([1, Y, Y^2]); O
    187             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     194            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
     195            sage: O = L.order_with_basis([1, y, y^2]); O
     196            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    188197            sage: O.basis()
    189             (1, Y, Y^2)
     198            (1, y, y^2)
    190199
    191200        Note that 1 does not need to be an element of the basis, as long it is in the module spanned by it::
    192201
    193             sage: O = L.order_with_basis([1+Y, Y, Y^2]); O
    194             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     202            sage: O = L.order_with_basis([1+y, y, y^2]); O
     203            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    195204            sage: O.basis()
    196             (Y + 1, Y, Y^2)
     205            (y + 1, y, y^2)
    197206       
    198 
    199207        The following error is raised when the module spanned by the basis is not closed under multiplication::
    200208
    201             sage: O = L.order_with_basis([1, x^2 + x*Y, (2/3)*Y^2]); O
     209            sage: O = L.order_with_basis([1, x^2 + x*y, (2/3)*y^2]); O
    202210            Traceback (most recent call last):
    203211            ...
    204             ValueError: The module generated by basis [1, x*Y + x^2, 2/3*Y^2] must be closed under multiplication
     212            ValueError: The module generated by basis [1, x*y + x^2, 2/3*y^2] must be closed under multiplication
    205213           
    206214        and this happens when the identity is not in the module spanned by the basis::
    207215
    208             sage: O = L.order_with_basis([x, x^2 + x*Y, (2/3)*Y^2])
     216            sage: O = L.order_with_basis([x, x^2 + x*y, (2/3)*y^2])
    209217            Traceback (most recent call last):
    210218            ...
    211             ValueError: The identity element must be in the module spanned by basis [x, x*Y + x^2, 2/3*Y^2]
    212            
    213 
     219            ValueError: The identity element must be in the module spanned by basis [x, x*y + x^2, 2/3*y^2]
    214220        """
    215221        from function_field_order import FunctionFieldOrder_basis
    216222        return FunctionFieldOrder_basis([self(a) for a in basis], check=check)
    class FunctionField(Field): 
    228234
    229235        EXAMPLES::
    230236
    231             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
    232             sage: O = L.order(Y); O
    233             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     237            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
     238            sage: O = L.order(y); O
     239            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    234240            sage: O.basis()
    235             (1, Y, Y^2)
     241            (1, y, y^2)
    236242
    237243            sage: Z = K.order(x); Z
    238244            Order in Rational function field in x over Rational Field
    class FunctionField(Field): 
    263269
    264270        EXAMPLES::
    265271
    266             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^3 + x^3 + 4*x + 1)
     272            sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<y> = K.extension(y^3 + x^3 + 4*x + 1)
    267273            sage: L.equation_order()
    268             Order in Function field in Y defined by y^3 + x^3 + 4*x + 1
     274            Order in Function field in y defined by y^3 + x^3 + 4*x + 1
    269275            sage: L._coerce_map_from_(L.equation_order())
    270276            True
    271277            sage: L._coerce_map_from_(GF(7))
    class FunctionField_polymod(FunctionField): 
    281287    A function field defined by a univariate polynomial, as an
    282288    extension of the base field.
    283289   
    284     EXAMPLES::
     290    EXAMPLES:
    285291
    286292    We make a function field defined by a degree 5 polynomial over the
    287293    rational function field over the rational numbers::
    288294   
    289295        sage: K.<x> = FunctionField(QQ)
    290296        sage: R.<y> = K[]
    291         sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    292         Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     297        sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     298        Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    293299
    294300    We next make a function field over the above nontrivial function
    295301    field L::
    296302
    297         sage: S.<T> = L[]
    298         sage: M.<alpha> = L.extension(T^2 + w*T + y); M
    299         Function field in alpha defined by T^2 + w*T + w
    300         sage: 1/alpha
    301         ((x/(-x^4 - 1))*w^4 - 2*x^2/(-x^4 - 1))*alpha - 1
    302         sage: alpha * (1/alpha)
     303        sage: S.<z> = L[]
     304        sage: M.<z> = L.extension(z^2 + y*z + y); M
     305        Function field in z defined by z^2 + y*z + y
     306        sage: 1/z
     307        ((x/(-x^4 - 1))*y^4 - 2*x^2/(-x^4 - 1))*z - 1
     308        sage: z * (1/z)
    303309        1
    304310
    305311    We drill down the tower of function fields::
    306312   
    307313        sage: M.base_field()
    308         Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     314        Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    309315        sage: M.base_field().base_field()
    310316        Rational function field in x over Rational Field
    311317        sage: M.base_field().base_field().constant_field()
    class FunctionField_polymod(FunctionField): 
    315321
    316322    .. WARNING::
    317323
    318         It is not checked if the polynomial used to define this function field is irriducible
     324        It is not checked if the polynomial used to define this function field is irreducible
    319325        Hence it is not guaranteed that this object really is a field!
    320326        This is illustrated below.
    321327
    class FunctionField_polymod(FunctionField): 
    323329
    324330        sage: K.<x>=FunctionField(QQ)
    325331        sage: R.<y> = K[]
    326         sage: L.<w>=K.extension(x^2-y^2)
    327         sage: (w-x)*(w+x)
     332        sage: L.<y>=K.extension(x^2-y^2)
     333        sage: (y-x)*(y+x)
    328334        0
    329         sage: 1/(w-x)
     335        sage: 1/(y-x)
    330336        1
    331         sage: w-x==0; w+x==0
     337        sage: y-x==0; y+x==0
    332338        False
    333339        False
    334        
    335340    """
    336341    def __init__(self, polynomial, names,
    337342            element_class = function_field_element.FunctionFieldElement_polymod,
    class FunctionField_polymod(FunctionField): 
    348353       
    349354        EXAMPLES::
    350355
    351         We create an extension of function fields::
     356        We create an extension of a function field::
    352357       
    353358            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    354359            sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
    class FunctionField_polymod(FunctionField): 
    363368       
    364369            sage: L.<w> = K.extension(y^5 - x^3 - 3*x + x*y); L
    365370            Function field in w defined by y^5 + x*y - x^3 - 3*x
    366 
    367371        """
    368372        from sage.rings.polynomial.all import is_Polynomial
    369373        if polynomial.parent().ngens()>1 or not is_Polynomial(polynomial):
    class FunctionField_polymod(FunctionField): 
    389393        self._gen = self(self._ring.gen())
    390394
    391395    def __reduce__(self):
     396        """
     397        Returns the arguments which were used to create this instance. The rationale for this is explained in the documentation of ``UniqueRepresentation``.
     398
     399        EXAMPLES::
     400
     401            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     402            sage: L = K.extension(y^2-x)
     403            sage: clazz,args = L.__reduce__()
     404            sage: clazz(*args)
     405            Function field in y defined by y^2 - x
     406        """
    392407        from constructor import FunctionField_polymod as FunctionField_polymod_Constructor
    393408        return  FunctionField_polymod_Constructor, (self._polynomial, self._names)
    394409
    class FunctionField_polymod(FunctionField): 
    402417            sage: L = K.extension(y^5 - x^3 - 3*x + x*y); hash(L)
    403418            3183366741743088279             # 64-bit
    404419            2003022487                      # 32-bit
    405 
    406420        """
    407421        return self._hash
    408422
    class FunctionField_polymod(FunctionField): 
    411425        Return a function field isomorphic to self, but with defining
    412426        polynomial that is monic and integral over the base field.
    413427
    414         INPUT::
     428        INPUT:
    415429
    416430            - ``names`` -- name of the generator of the new field this function constructs
    417431
    418432        EXAMPLES::
    419433
    420434            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    421             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
    422             Function field in alpha defined by x^2*y^5 - 1/x
    423             sage: A, from_A, to_A = L.monic_integral_model('beta')
     435            sage: L.<y> = K.extension(x^2*y^5 - 1/x); L
     436            Function field in y defined by x^2*y^5 - 1/x
     437            sage: A, from_A, to_A = L.monic_integral_model('z')
    424438            sage: A
    425             Function field in beta defined by y^5 - x^12
     439            Function field in z defined by y^5 - x^12
    426440            sage: from_A
    427             Morphism of function fields defined by beta |--> x^3*alpha
     441            Morphism of function fields defined by z |--> x^3*y
    428442            sage: to_A
    429             Morphism of function fields defined by alpha |--> 1/x^3*beta
    430             sage: to_A(alpha)
    431             1/x^3*beta
    432             sage: from_A(to_A(alpha))
    433             alpha
    434             sage: from_A(to_A(1/alpha))
    435             x^3*alpha^4
    436             sage: from_A(to_A(1/alpha)) == 1/alpha
    437             True           
     443            Morphism of function fields defined by y |--> 1/x^3*z
     444            sage: to_A(y)
     445            1/x^3*z
     446            sage: from_A(to_A(y))
     447            y
     448            sage: from_A(to_A(1/y))
     449            x^3*y^4
     450            sage: from_A(to_A(1/y)) == 1/y
     451            True
    438452        """
    439453        g, d = self._make_monic_integral(self.polynomial())
    440454        R = self.base_field()
    class FunctionField_polymod(FunctionField): 
    445459
    446460    def _make_monic_integral(self, f):
    447461        r"""
    448         Let alpha be a root of f.  This function returns a monic
     462        Let y be a root of ``f``.  This function returns a monic
    449463        integral polynomial g and an element d of the base field such
    450         that g(alpha*d) = 0.
     464        that g(y*d)=0.
    451465       
    452466        EXAMPLES::
    453467       
    454468            sage: K.<x> = FunctionField(QQ); R.<y> = K[];
    455             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x)
     469            sage: L.<y> = K.extension(x^2*y^5 - 1/x)
    456470            sage: g, d = L._make_monic_integral(L.polynomial()); g,d
    457471            (y^5 - x^12, x^3)
    458             sage: (alpha*d).is_integral()
     472            sage: (y*d).is_integral()
    459473            True
    460474            sage: g.is_monic()
    461475            True
    462             sage: g(alpha*d)
     476            sage: g(y*d)
    463477            0
    464        
    465478        """
    466479        R = f.base_ring()
    467480        if not isinstance(R, RationalFunctionField):
    class FunctionField_polymod(FunctionField): 
    492505        EXAMPLES::
    493506
    494507            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    495             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     508            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    496509            sage: L.constant_field()
    497510            Traceback (most recent call last):
    498511            ...
    class FunctionField_polymod(FunctionField): 
    507520        EXAMPLES::
    508521
    509522            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    510             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    511             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     523            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     524            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    512525            sage: L.constant_base_field()
    513526            Rational Field
    514527            sage: S.<z> = L[]
    515             sage: M.<z> = L.extension(z^2 - w)
     528            sage: M.<z> = L.extension(z^2 - y)
    516529            sage: M.constant_base_field()
    517530            Rational Field
    518            
    519531        """
    520532        return self.base_field().constant_base_field()
    521533
    class FunctionField_polymod(FunctionField): 
    528540
    529541            sage: K.<x> = FunctionField(QQ)
    530542            sage: R.<y> = K[]
    531             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    532             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     543            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     544            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    533545            sage: L.degree()
    534             5       
    535              
     546            5
    536547        """
    537548        return self._polynomial.degree()
    538549       
    class FunctionField_polymod(FunctionField): 
    543554        EXAMPLES::
    544555
    545556            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    546             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     557            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    547558            sage: L._repr_()
    548             'Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x'
    549        
     559            'Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x'
    550560        """
    551561        return "Function field in %s defined by %s"%(self.variable_name(), self._polynomial)
    552562
    class FunctionField_polymod(FunctionField): 
    557567        by definition the field K.
    558568       
    559569        EXAMPLES::
     570
    560571            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    561             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     572            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    562573            sage: L.base_field()
    563574            Rational function field in x over Rational Field
    564        
    565575        """
    566576        return self._base_field
    567577
    568 
    569578    def random_element(self, *args, **kwds):
    570579        """
    571580        Create a random element of this function field.  Parameters
    class FunctionField_polymod(FunctionField): 
    574583        EXAMPLES::
    575584
    576585            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    577             sage: L.<w> = K.extension(y^2 - (x^2 + x))
     586            sage: L.<y> = K.extension(y^2 - (x^2 + x))
    578587            sage: L.random_element() # random
    579             ((x^2 - x + 2/3)/(x^2 + 1/3*x - 1))*w^2 + ((-1/4*x^2 + 1/2*x - 1)/(-5/2*x + 2/3))*w + (-1/2*x^2 - 4)/(-12*x^2 + 1/2*x - 1/95)
    580        
     588            ((x^2 - x + 2/3)/(x^2 + 1/3*x - 1))*y^2 + ((-1/4*x^2 + 1/2*x - 1)/(-5/2*x + 2/3))*y + (-1/2*x^2 - 4)/(-12*x^2 + 1/2*x - 1/95)
    581589        """
    582590        return self(self._ring.random_element(degree=self.degree(), *args, **kwds))
    583591
    class FunctionField_polymod(FunctionField): 
    590598        EXAMPLES::
    591599
    592600            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    593             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     601            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    594602            sage: L.polynomial()
    595603            y^5 - 2*x*y + (-x^4 - 1)/x
    596        
    597604        """
    598605        return self._polynomial
    599606
    600607    def polynomial_ring(self):
    601608        """
    602         Return the polynomial ring used to represents elements of this
     609        Return the polynomial ring used to represent elements of this
    603610        function field.  If we view this function field as being presented
    604611        as K[y]/(f(y)), then this function returns the ring K[y].
    605612       
    606613        EXAMPLES::
    607614
    608615            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    609             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     616            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    610617            sage: L.polynomial_ring()
    611618            Univariate Polynomial Ring in y over Rational function field in x over Rational Field
    612        
    613619        """
    614620        return self._ring
    615621
    class FunctionField_polymod(FunctionField): 
    625631       
    626632        OUTPUT:
    627633
    628             -  ``V`` - a vector space over base field
    629             -  ``from_V`` - an isomorphism from V to self
    630             -  ``to_V`` - an isomorphism from self to V
     634            -  ``V`` -- a vector space over base field
     635            -  ``from_V`` -- an isomorphism from V to self
     636            -  ``to_V`` -- an isomorphism from self to V
    631637
    632         EXAMPLES::
     638        EXAMPLES:
    633639
    634640        We define a function field::
    635641       
    636642            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    637             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
    638             Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     643            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x)); L
     644            Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    639645
    640646        We get the vector spaces, and maps back and forth::
    641647       
    class FunctionField_polymod(FunctionField): 
    643649            sage: V
    644650            Vector space of dimension 5 over Rational function field in x over Rational Field
    645651            sage: from_V
    646             Isomorphism map:
     652            Isomorphism morphism:
    647653              From: Vector space of dimension 5 over Rational function field in x over Rational Field
    648               To:   Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     654              To:   Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    649655            sage: to_V
    650             Isomorphism map:
    651               From: Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     656            Isomorphism morphism:
     657              From: Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
    652658              To:   Vector space of dimension 5 over Rational function field in x over Rational Field
    653659
    654660        We convert an element of the vector space back to the function field::
    655661       
    656662            sage: from_V(V.1)
    657             w
     663            y
    658664
    659665        We define an interesting element of the function field::
    660666       
    661667            sage: a = 1/L.0; a
    662             (-x/(-x^4 - 1))*w^4 + 2*x^2/(-x^4 - 1)
     668            (-x/(-x^4 - 1))*y^4 + 2*x^2/(-x^4 - 1)
    663669
    664670        We convert it to the vector space, and get a vector over the base field::
    665671       
    class FunctionField_polymod(FunctionField): 
    677683            sage: to_V(from_V(v)) == v
    678684            True
    679685
     686        And we show how it works over an extension of an extension field::
    680687
    681         And we show how it works over an extension of an extension field.
    682 
    683             sage: R2.<z> = L[]; M.<w> = L.extension(z^2 -y)
     688            sage: R2.<z> = L[]; M.<z> = L.extension(z^2 -y)
    684689            sage: M.vector_space()
    685             (Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x, Isomorphism map:
    686               From: Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
    687               To:   Function field in w defined by z^2 - w, Isomorphism map:
    688               From: Function field in w defined by z^2 - w
    689               To:   Vector space of dimension 2 over Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x)
    690                    
     690            (Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x, Isomorphism morphism:
     691              From: Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
     692              To:   Function field in z defined by z^2 - y, Isomorphism morphism:
     693              From: Function field in z defined by z^2 - y
     694              To:   Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x)
    691695        """
    692696        V = self.base_field()**self.degree()
    693697        from maps import MapVectorSpaceToFunctionField, MapFunctionFieldToVectorSpace
    class FunctionField_polymod(FunctionField): 
    696700        self._vector_space = (V, from_V, to_V)
    697701        return self._vector_space
    698702       
    699 
    700703    def maximal_order(self):
    701704        """
    702705        Return the maximal_order of self.  If we view self as L =
    703706        K[y]/(f(y)), then this is the ring of elements of L that are
    704707        integral over K.
    705708       
    706         EXAMPLES::
     709        EXAMPLES:
    707710
    708711        This is not yet implemented...::
    709712       
    710713            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    711             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     714            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    712715            sage: L.maximal_order()
    713716            Traceback (most recent call last):
    714717            ...
    715718            NotImplementedError
    716        
    717719        """
    718720        raise NotImplementedError
    719721
    720722    def _element_constructor_(self, x):
    721723        r"""
    722         Make x into an element of this function field, possibly not canonically.
     724        Make ``x`` into an element of this function field, possibly not canonically.
    723725
    724726        INPUT:
    725727       
    726             - ``x`` - the element
     728            - ``x`` -- the element
    727729         
    728730        OUTPUT:
    729731       
    class FunctionField_polymod(FunctionField): 
    732734        TESTS::
    733735
    734736            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    735             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     737            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    736738            sage: L._element_constructor_(L.polynomial_ring().gen())
    737             w
     739            y
    738740        """
    739741        if x.parent() is self._ring:
    740742            return function_field_element.FunctionFieldElement_polymod(self, x)
    class FunctionField_polymod(FunctionField): 
    745747
    746748    def gen(self, n=0):
    747749        """
    748         Return the n-th generator of this function field.  By default n=0; any other
    749         value of n leads to an error.  The generator is the class of y, if we view
     750        Return the ``n``-th generator of this function field. By default ``n`` is 0; any other
     751        value of ``n`` leads to an error. The generator is the class of y, if we view
    750752        self as being presented as K[y]/(f(y)).
    751753       
    752754        EXAMPLES::
    753755
    754756            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    755             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     757            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    756758            sage: L.gen()
    757             w
     759            y
    758760            sage: L.gen(1)
    759761            Traceback (most recent call last):
    760762            ...
    761763            IndexError: Only one generator.
    762 
    763764        """
    764765        if n != 0: raise IndexError, "Only one generator."
    765766        return self._gen
    class FunctionField_polymod(FunctionField): 
    772773        EXAMPLES::
    773774       
    774775            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    775             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     776            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    776777            sage: L.ngens()
    777778            1
    778779        """
    class FunctionField_polymod(FunctionField): 
    782783        """
    783784        If we view self as being presented as K[y]/(f(y)), then this
    784785        function returns the order generated by the class of y.  If f
    785         is not monic, then self._make_monic_integral is called, and instead we
    786         get the order generated by some integral multiple of a root of
    787         alpha.
     786        is not monic, then :meth:`_make_monic_integral` is called, and instead we
     787        get the order generated by some integral multiple of a root of f.
    788788       
    789789        EXAMPLES::
    790790
    791791            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    792             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    793             sage: L.equation_order()
    794             Order in Function field in w defined by y^5 - 2*x*y + (-x^4 - 1)/x
     792            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     793            sage: O = L.equation_order()
     794            sage: O.basis()
     795            (1, x*y, x^2*y^2, x^3*y^3, x^4*y^4)
    795796
    796797        We try an example, in which the defining polynomial is not
    797798        monic and is not integral::
    798799
    799800            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
    800             sage: L.<alpha> = K.extension(x^2*y^5 - 1/x); L
    801             Function field in alpha defined by x^2*y^5 - 1/x
    802             sage: O = L.equation_order(); O
    803             Order in Function field in alpha defined by x^2*y^5 - 1/x
     801            sage: L.<y> = K.extension(x^2*y^5 - 1/x); L
     802            Function field in y defined by x^2*y^5 - 1/x
     803            sage: O = L.equation_order()
    804804            sage: O.basis()
    805             (1, x^3*alpha, x^6*alpha^2, x^9*alpha^3, x^12*alpha^4)
    806        
     805            (1, x^3*y, x^6*y^2, x^9*y^3, x^12*y^4)
    807806        """
    808807        d = self._make_monic_integral(self.polynomial())[1]
    809808        return self.order(d*self.gen(), check=False)
    810    
    811809
    812810    def hom(self, im_gens, base_morphism=None):
    813811        """
    class RationalFunctionField(FunctionField): 
    945943
    946944    We define a morphism::
    947945
    948         sage: K.<W> = FunctionField(QQ)
    949         sage: L = FunctionField(QQ, 'tbar')         # give var name as second input
     946        sage: K.<t> = FunctionField(QQ)
     947        sage: L = FunctionField(QQ, 'tbar') # give variable name as second input
    950948        sage: K.hom(L.gen())
    951         Morphism of function fields defined by W |--> tbar
     949        Morphism of function fields defined by t |--> tbar
    952950    """
    953951    def __init__(self, constant_field, names,
    954952            element_class = function_field_element.FunctionFieldElement_rational,
    class RationalFunctionField(FunctionField): 
    996994        self._gen = self(R.gen())
    997995
    998996    def __reduce__(self):
     997        """
     998        Returns the arguments which were used to create this instance. The rationale for this is explained in the documentation of ``UniqueRepresentation``.
     999
     1000        EXAMPLES::
     1001
     1002            sage: K.<x> = FunctionField(QQ)
     1003            sage: clazz,args = K.__reduce__()
     1004            sage: clazz(*args)
     1005            Rational function field in x over Rational Field
     1006        """
    9991007        return constructor.FunctionField, (self._constant_field, self._names)
    10001008   
    10011009    def __hash__(self):
    class RationalFunctionField(FunctionField): 
    10081016            sage: hash(K)
    10091017            502145503910697533              # 64-bit
    10101018            -500688323                      # 32-bit
    1011                        
    10121019        """
    10131020        return self._hash
    10141021
    class RationalFunctionField(FunctionField): 
    10211028            sage: K.<t> = FunctionField(QQ)
    10221029            sage: K._repr_()
    10231030            'Rational function field in t over Rational Field'
    1024 
    10251031        """
    10261032        return "Rational function field in %s over %s"%(
    10271033            self.variable_name(), self._constant_field)
    10281034
    10291035    def _element_constructor_(self, x):
    10301036        r"""
    1031         Coerce x into an element of this function field, possibly not canonically.
     1037        Coerce ``x`` into an element of this function field, possibly not canonically.
    10321038
    10331039        INPUT:
    10341040       
    1035             - ``x`` - the element
     1041            - ``x`` -- the element
    10361042         
    10371043        OUTPUT:
    10381044       
    class RationalFunctionField(FunctionField): 
    10621068            return x[0]
    10631069        return function_field_element.FunctionFieldElement_rational(self, self._field(x))
    10641070
    1065     # nonoptimized
    10661071    def _to_bivariate_polynomial(self, f):
    10671072        """
    1068         Convert f from a univariate polynomial over the rational function
     1073        Convert ``f`` from a univariate polynomial over the rational function
    10691074        field into a bivariate polynomial and a denominator.
    10701075
    10711076        INPUT:
    10721077
    1073             - f -- a univariate polynomial over self.
     1078            - ``f`` -- a univariate polynomial over self.
    10741079
    10751080        OUTPUT:
    10761081
    1077             - 2-variate polynomial, denominator
     1082            - bivariate polynomial, denominator
    10781083
    10791084        EXAMPLES::
    10801085       
    class RationalFunctionField(FunctionField): 
    10941099
    10951100    def _factor_univariate_polynomial(self, f, proof=True):
    10961101        """
    1097         Factor the univariate polynomial f over self.
     1102        Factor the univariate polynomial ``f`` over self.
    10981103
    10991104        EXAMPLES::
    11001105
    class RationalFunctionField(FunctionField): 
    11061111            sage: f.factor()             # indirect doctest
    11071112            (1/t) * (X - t) * (X^2 - 1/t) * (X^2 + 1/t) * (X^2 + t*X + t^2)
    11081113            sage: f.factor().prod() == f
    1109             True       
     1114            True
    11101115
    1111         You must pass in proof=False over finite fields, due to
     1116        You must pass in ``proof=False`` over finite fields, due to
    11121117        Singular's factoring algorithm being incomplete::
    11131118
    11141119            sage: R.<t> = FunctionField(GF(7))
    class RationalFunctionField(FunctionField): 
    11331138            (1/t) * (X + (a + 2)*t)^3
    11341139            sage: f.factor(proof=False).prod() == f
    11351140            True
    1136 
    11371141        """
    11381142        F, d = self._to_bivariate_polynomial(f)
    11391143        fac = F.factor(proof=proof)
    class RationalFunctionField(FunctionField): 
    11541158    @cached_method
    11551159    def polynomial_ring(self, var='x'):
    11561160        """
    1157         Return polynomial ring K[var] that could be used to represent
    1158         elements of self, if self were viewed as K[var]/(var).
     1161        Return a polynomial ring in one variable over this rational function field.
    11591162       
     1163        INPUT:
     1164
     1165            - ``var`` -- a string (default: 'x')
     1166
    11601167        EXAMPLES::
    11611168       
    11621169            sage: K.<x> = FunctionField(QQ)
    class RationalFunctionField(FunctionField): 
    11641171            Univariate Polynomial Ring in x over Rational function field in x over Rational Field
    11651172            sage: K.polynomial_ring('T')
    11661173            Univariate Polynomial Ring in T over Rational function field in x over Rational Field
    1167        
    11681174        """
    1169         if var != 'x': return self[var]
    1170         try: return self._polynomial_ring
    1171         except AttributeError:
    1172             self._polynomial_ring = self[var]
    1173             return self._polynomial_ring
     1175        return self[var]
    11741176
     1177    @cached_method
    11751178    def vector_space(self):
    11761179        """
    11771180        Return a vector space V and isomorphisms self --> V and V --> self.
    11781181       
    11791182        OUTPUT:
    11801183
    1181             -  ``V`` - a vector space over the rational numbers
    1182             -  ``from_V`` - an isomorphism from V to self
    1183             -  ``to_V`` - an isomorphism from self to V
     1184            -  ``V`` -- a vector space over the rational numbers
     1185            -  ``from_V`` -- an isomorphism from V to self
     1186            -  ``to_V`` -- an isomorphism from self to V
    11841187
    11851188        EXAMPLES::
    11861189
    11871190            sage: K.<x> = FunctionField(QQ)
    11881191            sage: K.vector_space()
    1189             (Vector space of dimension 1 over Rational function field in x over Rational Field, Isomorphism map:
     1192            (Vector space of dimension 1 over Rational function field in x over Rational Field, Isomorphism morphism:
    11901193              From: Vector space of dimension 1 over Rational function field in x over Rational Field
    1191               To:   Rational function field in x over Rational Field, Isomorphism map:
     1194              To:   Rational function field in x over Rational Field, Isomorphism morphism:
    11921195              From: Rational function field in x over Rational Field
    11931196              To:   Vector space of dimension 1 over Rational function field in x over Rational Field)
    1194        
    11951197        """
    11961198        V = self.base_field()**1
    11971199        from maps import MapVectorSpaceToFunctionField, MapFunctionFieldToVectorSpace
    class RationalFunctionField(FunctionField): 
    12101212
    12111213            sage: FunctionField(QQ,'alpha').random_element()
    12121214            (-1/2*alpha^2 - 4)/(-12*alpha^2 + 1/2*alpha - 1/95)
    1213        
    12141215        """
    12151216        return self(self._field.random_element(*args, **kwds))
    12161217
    12171218    def degree(self):
    12181219        """
    12191220        Return the degree over the base field of this rational
    1220         function field, which is 1.
    1221        
     1221        function field. Since the base field is the rational function
     1222        field itself, the degree is 1.
     1223
    12221224        EXAMPLES::
    12231225       
    12241226            sage: K.<t> = FunctionField(QQ)
    12251227            sage: K.degree()
    12261228            1
    1227        
    12281229        """
    12291230        return ZZ(1)
    12301231   
    12311232    def gen(self, n=0):
    12321233        """
    1233         Return the n-th generator of this function field.  If n is not
     1234        Return the ``n``-th generator of this function field.  If ``n`` is not
    12341235        0, then an IndexError is raised.
    12351236
    12361237        EXAMPLES::
    class RationalFunctionField(FunctionField): 
    12571258            sage: K.<t> = FunctionField(QQ)
    12581259            sage: K.ngens()
    12591260            1
    1260        
    12611261        """
    12621262        return 1
    12631263   
    class RationalFunctionField(FunctionField): 
    12711271            sage: K.<t> = FunctionField(GF(7))
    12721272            sage: K.base_field()
    12731273            Rational function field in t over Finite Field of size 7
    1274        
    12751274        """
    12761275        return self
    12771276
    class RationalFunctionField(FunctionField): 
    12881287
    12891288            - a map between function fields
    12901289
    1291         EXAMPLES::
     1290        EXAMPLES:
    12921291
    12931292        We make a map from a rational function field to itself::
    12941293
    1295             sage: R.<x> = FunctionField(GF(7))
    1296             sage: R.hom( (x^4 + 2)/x)
     1294            sage: K.<x> = FunctionField(GF(7))
     1295            sage: K.hom( (x^4 + 2)/x)
    12971296            Morphism of function fields defined by x |--> (x^4 + 2)/x       
    12981297       
    12991298        We construct a map from a rational function field into a
    13001299        non-rational extension field::
    13011300       
    1302             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    1303             sage: L.<y> = R.extension(y^3 + 6*x^3 + x)
    1304             sage: f = R.hom(y^2 + y  + 2); f
     1301            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     1302            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     1303            sage: f = K.hom(y^2 + y  + 2); f
    13051304            Morphism of function fields defined by x |--> y^2 + y + 2
    13061305            sage: f(x)
    13071306            y^2 + y + 2
    13081307            sage: f(x^2)
    13091308            5*y^2 + (x^3 + 6*x + 4)*y + 2*x^3 + 5*x + 4       
    1310        
    13111309        """
    13121310        if isinstance(im_gens, CategoryObject):
    13131311            return self.Hom(im_gens).natural_map()
    class RationalFunctionField(FunctionField): 
    13281326            sage: K.<t> = FunctionField(GF(7))
    13291327            sage: K.field()
    13301328            Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 7
    1331        
    13321329        """
    13331330        return self._field
    13341331
    class RationalFunctionField(FunctionField): 
    13461343            Maximal order in Rational function field in t over Rational Field
    13471344            sage: K.equation_order()
    13481345            Maximal order in Rational function field in t over Rational Field
    1349        
    13501346        """
    13511347        from function_field_order import FunctionFieldOrder_rational
    13521348        return FunctionFieldOrder_rational(self)
    class RationalFunctionField(FunctionField): 
    13681364        return self._constant_field
    13691365
    13701366    constant_field = constant_base_field
    1371 
    1372 
    1373        
    1374 
    1375    
    1376 
    1377 
  • sage/rings/function_field/function_field_element.pyx

    diff --git a/sage/rings/function_field/function_field_element.pyx b/sage/rings/function_field/function_field_element.pyx
    index 9d0babd..1972aa6 100644
    a b def make_FunctionFieldElement(parent, element_class, representing_element): 
    2828        sage: K.<x> = FunctionField(QQ)
    2929        sage: make_FunctionFieldElement(K, K._element_class, (x+1)/x)
    3030        (x + 1)/x
    31    
    3231    """
    3332    return element_class(parent, representing_element, reduce=False)
    3433
    3534cdef class FunctionFieldElement(FieldElement):
    36 
    37     cdef readonly object _x
    38     cdef readonly object _matrix
    39    
    4035    """
    4136    The abstract base class for function field elements.
    4237   
    cdef class FunctionFieldElement(FieldElement): 
    4742        True
    4843    """
    4944
     45    cdef readonly object _x
     46    cdef readonly object _matrix
     47
    5048    def __reduce__(self):
    5149        """
    5250        EXAMPLES::
    cdef class FunctionFieldElement(FieldElement): 
    5957        return (make_FunctionFieldElement,
    6058                (self._parent, type(self), self._x))
    6159
    62 
    6360    cdef FunctionFieldElement _new_c(self):
    6461        cdef FunctionFieldElement x = <FunctionFieldElement>PY_NEW_SAME_TYPE(self)
    6562        x._parent = self._parent
    cdef class FunctionFieldElement(FieldElement): 
    8178   
    8279    def matrix(self):
    8380        r"""
    84         Return the matrix of multiplication by self when seeing the function field
    85         of where self is an element of as a vectorspace over its base field.
     81        Return the matrix of multiplication by self, interpreting self as an element
     82        of a vector space over its base field.
    8683
    87         EXAMPLES::
     84        EXAMPLES:
    8885
    89         A rational function field:
     86        A rational function field::
    9087       
    9188            sage: K.<t> = FunctionField(QQ)
    9289            sage: t.matrix()
    cdef class FunctionFieldElement(FieldElement): 
    9693
    9794        Now an example in a nontrivial extension of a rational function field::
    9895       
    99             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    100             sage: Y.matrix()
     96            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     97            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     98            sage: y.matrix()
    10199            [     0      1]
    102100            [-4*x^3      x]
    103             sage: Y.matrix().charpoly('Z')
     101            sage: y.matrix().charpoly('Z')
    104102            Z^2 - x*Z + 4*x^3
    105103
    106104        An example in a relative extension, where neither function
    107105        field is rational::
    108106
    109             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    110             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     107            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     108            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     109            sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - y^2*T + x)
    111110            sage: alpha.matrix()
    112111            [          0           1           0]
    113112            [          0           0           1]
    114             [         -x x*Y - 4*x^3           0]
     113            [         -x x*y - 4*x^3           0]
    115114
    116         We show that this matrix does indeed works as expected when making a
    117         vectorspace from a function field::
     115        We show that this matrix does indeed work as expected when making a
     116        vector space from a function field::
    118117
    119118            sage: K.<x>=FunctionField(QQ)
    120119            sage: R.<y> = K[]
    121             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
     120            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x))
    122121            sage: V, from_V, to_V = L.vector_space()
    123             sage: w5 = to_V(w^5)
    124             sage: w5 = to_V(w^5); w5
     122            sage: y5 = to_V(y^5); y5
    125123            ((x^4 + 1)/x, 2*x, 0, 0, 0)
    126             sage: w4xw = to_V(w^4) * w.matrix(); w4xw
     124            sage: y4y = to_V(y^4) * y.matrix(); y4y
    127125            ((x^4 + 1)/x, 2*x, 0, 0, 0)
    128             sage: w5 == w4xw
     126            sage: y5 == y4y
    129127            True
    130        
    131128        """
    132129        if self._matrix is None:
    133130            # Multiply each power of field generator on the left by this
    cdef class FunctionFieldElement(FieldElement): 
    153150
    154151        EXAMPLES::
    155152
    156             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    157             sage: Y.trace()
     153            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     154            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     155            sage: y.trace()
    158156            x
    159157        """
    160158        return self.matrix().trace()
    cdef class FunctionFieldElement(FieldElement): 
    165163
    166164        EXAMPLES::
    167165       
    168             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    169             sage: Y.norm()
     166            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     167            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     168            sage: y.norm()
    170169            4*x^3
    171170
    172 
    173171        The norm is relative::
    174172       
    175             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    176             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
    177             sage: alpha.norm()
     173            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     174            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     175            sage: M.<z> = L.extension(z^3 - y^2*z + x)
     176            sage: z.norm()
    178177            -x
    179             sage: alpha.norm().parent()
    180             Function field in Y defined by y^2 - x*y + 4*x^3
     178            sage: z.norm().parent()
     179            Function field in y defined by y^2 - x*y + 4*x^3
    181180        """
    182181        return self.matrix().determinant()
    183182
    cdef class FunctionFieldElement(FieldElement): 
    189188
    190189        EXAMPLES::
    191190
    192             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    193             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     191            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     192            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     193            sage: M.<z> = L.extension(z^3 - y^2*z + x)
    194194            sage: x.characteristic_polynomial('W')
    195195            W - x
    196             sage: Y.characteristic_polynomial('W')
     196            sage: y.characteristic_polynomial('W')
    197197            W^2 - x*W + 4*x^3
    198             sage: alpha.characteristic_polynomial('W')
    199             W^3 + (-x*Y + 4*x^3)*W + x
     198            sage: z.characteristic_polynomial('W')
     199            W^3 + (-x*y + 4*x^3)*W + x
    200200        """
    201201        return self.matrix().characteristic_polynomial(*args, **kwds)
    202202
    cdef class FunctionFieldElement(FieldElement): 
    210210
    211211        EXAMPLES::
    212212
    213             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    214             sage: M.<T> = L[]; Z.<alpha> = L.extension(T^3 - Y^2*T + x)
     213            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     214            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3); R.<z> = L[]
     215            sage: M.<z> = L.extension(z^3 - y^2*z + x)
    215216            sage: x.minimal_polynomial('W')
    216217            W - x
    217             sage: Y.minimal_polynomial('W')
     218            sage: y.minimal_polynomial('W')
    218219            W^2 - x*W + 4*x^3
    219             sage: alpha.minimal_polynomial('W')
    220             W^3 + (-x*Y + 4*x^3)*W + x
     220            sage: z.minimal_polynomial('W')
     221            W^3 + (-x*y + 4*x^3)*W + x
    221222        """
    222223        return self.matrix().minimal_polynomial(*args, **kwds)
    223224
    cdef class FunctionFieldElement(FieldElement): 
    229230       
    230231        EXAMPLES::
    231232       
    232             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    233             sage: Y.is_integral()
     233            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     234            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     235            sage: y.is_integral()
    234236            True
    235             sage: (Y/x).is_integral()
     237            sage: (y/x).is_integral()
    236238            True
    237             sage: (Y/x)^2 - (Y/x) + 4*x
     239            sage: (y/x)^2 - (y/x) + 4*x
    238240            0
    239             sage: (Y/x^2).is_integral()
     241            sage: (y/x^2).is_integral()
    240242            False
    241             sage: f = (Y/x).minimal_polynomial('W'); f
     243            sage: (y/x).minimal_polynomial('W')
    242244            W^2 - W + 4*x           
    243245        """
    244246        R = self.parent().base_field().maximal_order()
    cdef class FunctionFieldElement(FieldElement): 
    246248
    247249cdef class FunctionFieldElement_polymod(FunctionFieldElement):
    248250    """
     251    Elements of a finite extension of a function field.
     252
    249253    EXAMPLES::
    250254
    251         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    252         sage: x*Y + 1/x^3
    253         x*Y + 1/x^3       
     255        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     256        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     257        sage: x*y + 1/x^3
     258        x*y + 1/x^3       
    254259    """
    255260    def __init__(self, parent, x, reduce=True):
    256261        """
    257262        EXAMPLES::
    258263
    259              sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    260              sage: type(Y)
    261              <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_polymod'>             
     264            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     265            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     266            sage: type(y)
     267            <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_polymod'>             
    262268        """
    263269        FieldElement.__init__(self, parent)
    264270        if reduce:
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    271277        Return the underlying polynomial that represents this element.
    272278       
    273279        EXAMPLES::
    274             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    275             sage: f = Y/x^2 + x/(x^2+1); f
    276             1/x^2*Y + x/(x^2 + 1)
    277             sage: f.element()
     280            sage: K.<x> = FunctionField(QQ); R.<T> = K[]
     281            sage: L.<y> = K.extension(T^2 - x*T + 4*x^3)
     282            sage: f = y/x^2 + x/(x^2+1); f
    278283            1/x^2*y + x/(x^2 + 1)
     284            sage: f.element()
     285            1/x^2*T + x/(x^2 + 1)
    279286            sage: type(f.element())
    280287            <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>       
    281288        """
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    285292        """
    286293        EXAMPLES::
    287294
    288             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    289             sage: Y._repr_()
    290             'Y'
     295            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     296            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     297            sage: y._repr_()
     298            'y'
    291299        """
    292300        return self._x._repr(name=self.parent().variable_name())
    293301       
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    295303        """
    296304        EXAMPLES::
    297305
    298             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    299             sage: bool(Y)
     306            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     307            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     308            sage: bool(y)
    300309            True
    301310            sage: bool(L(0))
    302311            False
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    309318        """
    310319        EXAMPLES::
    311320
    312             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     321            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     322            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    313323            sage: cmp(L(0), 0)
    314324            0
    315             sage: cmp(Y, L(2)) != 0
     325            sage: cmp(y, L(2)) != 0
    316326            True
    317327        """
    318328        cdef FunctionFieldElement left = <FunctionFieldElement>self
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    323333        """
    324334        EXAMPLES::
    325335
    326             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    327             sage: (2*Y + x/(1+x^3))  +  (3*Y + 5*x*Y)         # indirect doctest
    328             (5*x + 5)*Y + x/(x^3 + 1)
    329             sage: (Y^2 - x*Y + 4*x^3)==0                      # indirect doctest
     336            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     337            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     338            sage: (2*y + x/(1+x^3))  +  (3*y + 5*x*y)         # indirect doctest
     339            (5*x + 5)*y + x/(x^3 + 1)
     340            sage: (y^2 - x*y + 4*x^3)==0                      # indirect doctest
    330341            True
     342            sage: -y+y
     343            0
    331344        """
    332345        cdef FunctionFieldElement res = self._new_c()
    333346        res._x = self._x + (<FunctionFieldElement>right)._x
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    337350        """
    338351        EXAMPLES::
    339352
    340             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    341             sage: (2*Y + x/(1+x^3))  -  (3*Y + 5*x*Y)         # indirect doctest
    342             (-5*x - 1)*Y + x/(x^3 + 1)
     353            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     354            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     355            sage: (2*y + x/(1+x^3))  -  (3*y + 5*x*y)         # indirect doctest
     356            (-5*x - 1)*y + x/(x^3 + 1)
     357            sage: y-y
     358            0
    343359        """
    344360        cdef FunctionFieldElement res = self._new_c()
    345361        res._x = self._x - (<FunctionFieldElement>right)._x
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    349365        """
    350366        EXAMPLES::
    351367
    352             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    353             sage: Y  *  (3*Y + 5*x*Y)                          # indirect doctest
    354             (5*x^2 + 3*x)*Y - 20*x^4 - 12*x^3
     368            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     369            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     370            sage: y  *  (3*y + 5*x*y)                          # indirect doctest
     371            (5*x^2 + 3*x)*y - 20*x^4 - 12*x^3
    355372        """
    356373        cdef FunctionFieldElement res = self._new_c()
    357374        res._x = (self._x * (<FunctionFieldElement>right)._x) % self._parent.polynomial()
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    361378        """
    362379        EXAMPLES::
    363380
    364             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    365             sage: (2*Y + x/(1+x^3))  /  (2*Y + x/(1+x^3))       # indirect doctest
     381            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     382            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     383            sage: (2*y + x/(1+x^3))  /  (2*y + x/(1+x^3))       # indirect doctest
    366384            1
    367             sage: 1 / (Y^2 - x*Y + 4*x^3)                       # indirect doctest
     385            sage: 1 / (y^2 - x*y + 4*x^3)                       # indirect doctest
    368386            Traceback (most recent call last):
    369387            ...
    370388            ZeroDivisionError: Cannot invert 0
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    375393        """
    376394        EXAMPLES::
    377395
    378             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    379             sage: a = ~(2*Y + 1/x); a                           # indirect doctest
    380             (-x^2/(8*x^5 + x^2 + 1/2))*Y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
    381             sage: a*(2*Y + 1/x)
     396            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     397            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     398            sage: a = ~(2*y + 1/x); a                           # indirect doctest
     399            (-x^2/(8*x^5 + x^2 + 1/2))*y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
     400            sage: a*(2*y + 1/x)
    382401            1
    383402        """
    384403        if self.is_zero():
    cdef class FunctionFieldElement_polymod(FunctionFieldElement): 
    388407
    389408    def list(self):
    390409        """
     410        Return a list of coefficients of self, i.e., if self is an element of
     411        a function field K[y]/(f(y)), then return the coefficients of the
     412        reduced presentation as a polynomial in K[y].
     413
    391414        EXAMPLES::
    392415
    393             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
    394             sage: a = ~(2*Y + 1/x); a
    395             (-x^2/(8*x^5 + x^2 + 1/2))*Y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
     416            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     417            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
     418            sage: a = ~(2*y + 1/x); a
     419            (-x^2/(8*x^5 + x^2 + 1/2))*y + (2*x^3 + x)/(16*x^5 + 2*x^2 + 1)
    396420            sage: a.list()
    397421            [(2*x^3 + x)/(16*x^5 + 2*x^2 + 1), -x^2/(8*x^5 + x^2 + 1/2)]
    398             sage: (x*Y).list()
     422            sage: (x*y).list()
    399423            [0, x]
    400424        """
    401425        return self._x.padded_list(self.parent().degree())
    402426       
    403 
    404427cdef class FunctionFieldElement_rational(FunctionFieldElement):
    405428    """
     429    Elements of a rational function field.
     430
    406431    EXAMPLES::
    407432   
    408         sage: FunctionField(QQ, 't')
     433        sage: K.<t> = FunctionField(QQ); K
    409434        Rational function field in t over Rational Field
    410435    """
    411436    def __init__(self, parent, x, reduce=True):
    cdef class FunctionFieldElement_rational(FunctionFieldElement): 
    418443        FieldElement.__init__(self, parent)
    419444        self._x = x
    420445 
    421     # nonoptimized
    422 
    423446    def element(self):
    424447        """
    425448        Return the underlying fraction field element that represents this element.
    426449
    427450        EXAMPLES::
    428451
    429             sage: R.<a> = FunctionField(GF(7))
    430             sage: a.element()
    431             a
    432             sage: type(a.element())
     452            sage: K.<t> = FunctionField(GF(7))
     453            sage: t.element()
     454            t
     455            sage: type(t.element())
    433456            <type 'sage.rings.fraction_field_FpT.FpTElement'>       
    434457
    435             sage: R.<a> = FunctionField(GF(131101))
    436             sage: a.element()
    437             a
    438             sage: type(a.element())
     458            sage: K.<t> = FunctionField(GF(131101))
     459            sage: t.element()
     460            t
     461            sage: type(t.element())
    439462            <class 'sage.rings.fraction_field_element.FractionFieldElement_1poly_field'>
    440463        """
    441464        return self._x
    442465
    443466    def list(self):
    444467        """
     468        Return a list of coefficients of self, i.e., if self is an element of
     469        a function field K[y]/(f(y)), then return the coefficients of the
     470        reduced presentation as a polynomial in K[y].
     471        Since self is a member of a rational function field, this simply returns
     472        the list `[self]`
     473
    445474        EXAMPLES::
    446475
    447476            sage: K.<t> = FunctionField(QQ)
    cdef class FunctionFieldElement_rational(FunctionFieldElement): 
    507536        """
    508537        EXAMPLES::
    509538
    510 
    511539            sage: K.<t> = FunctionField(QQ)
    512540            sage: t - (3*t^3)                      # indirect doctest
    513541            -3*t^3 + t
    cdef class FunctionFieldElement_rational(FunctionFieldElement): 
    607635        """
    608636        Returns the square root of self.
    609637       
    610         EXMPLES::
     638        EXAMPLES::
    611639       
    612640            sage: K.<t> = FunctionField(QQ)
    613641            sage: f = t^2 - 2 + 1/t^2; f.sqrt()
    cdef class FunctionFieldElement_rational(FunctionFieldElement): 
    657685
    658686        EXAMPLES::
    659687
    660             sage: R.<x> = FunctionField(QQ)
    661             sage: S = R.maximal_order(); I = S.ideal(x^2+1)
    662             sage: t = S(x+1).inverse_mod(I); t
     688            sage: K.<x> = FunctionField(QQ)
     689            sage: O = K.maximal_order(); I = O.ideal(x^2+1)
     690            sage: t = O(x+1).inverse_mod(I); t
    663691            -1/2*x + 1/2
    664692            sage: (t*(x+1) - 1) in I
    665693            True           
  • sage/rings/function_field/function_field_ideal.py

    diff --git a/sage/rings/function_field/function_field_ideal.py b/sage/rings/function_field/function_field_ideal.py
    index 3a6a433..2ade1ae 100644
    a b  
     1r"""
     2Ideals in Function Fields.
     3
     4EXAMPLES:
     5
     6Ideals in the maximal order of a rational function field::
     7
     8    sage: K.<x> = FunctionField(QQ)
     9    sage: O = K.maximal_order()
     10    sage: I = O.ideal(x^3+1); I
     11    Ideal (x^3 + 1) of Maximal order in Rational function field in x over Rational Field
     12    sage: I^2
     13    Ideal (x^6 + 2*x^3 + 1) of Maximal order in Rational function field in x over Rational Field
     14    sage: ~I
     15    Ideal (1/(x^3 + 1)) of Maximal order in Rational function field in x over Rational Field
     16    sage: ~I * I
     17    Ideal (1) of Maximal order in Rational function field in x over Rational Field
     18
     19Ideals in the equation order of an extension of a rational function field::
     20
     21    sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     22    sage: L.<y> = K.extension(y^2-x^3-1)
     23    sage: O = L.equation_order()
     24    sage: I = O.ideal(y); I
     25    Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
     26    sage: I^2
     27    Ideal (x^3 + 1, (-x^3 - 1)*y) of Order in Function field in y defined by y^2 - x^3 - 1
     28    sage: ~I
     29    Ideal (-1, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 - x^3 - 1
     30    sage: ~I * I
     31    Ideal (1, y) of Order in Function field in y defined by y^2 - x^3 - 1
     32    sage: I.intersection(~I)
     33    Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
     34"""
    135from sage.rings.ideal import Ideal_generic
    236from sage.modules import free_module_element
     37
    338class FunctionFieldIdeal(Ideal_generic):
    439    """
    540    A fractional ideal of a function field.
    641
    742    EXAMPLES::
    843
    9         sage: R.<x> = FunctionField(GF(7))
    10         sage: S = R.maximal_order(); I = S.ideal(x^3+1)
     44        sage: K.<x> = FunctionField(GF(7))
     45        sage: O = K.maximal_order()
     46        sage: I = O.ideal(x^3+1)
    1147        sage: isinstance(I, sage.rings.function_field.function_field_ideal.FunctionFieldIdeal)
    1248        True   
    1349    """
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    2056
    2157    EXAMPLES::
    2258
    23     An ideal in a rational function field::
     59    An ideal in an extension of a rational function field::
    2460
    25         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    26         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    27         sage: I = M.ideal(y)
     61        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     62        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     63        sage: O = L.equation_order()
     64        sage: I = O.ideal(y)
    2865        sage: I
    2966        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
    3067        sage: I^2
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    3976
    4077        EXAMPLES::
    4178
    42             sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    43             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    44             sage: I = M.ideal(y)
     79            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     80            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     81            sage: O = L.equation_order()
     82            sage: I = O.ideal(y)
    4583            sage: type(I)
    4684            <class 'sage.rings.function_field.function_field_ideal.FunctionFieldIdeal_module'>
    4785        """
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    5896
    5997        EXAMPLES::
    6098
    61             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    62             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()
    63             sage: I = M.ideal_with_gens_over_base([1, y]);  I
     99            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     100            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     101            sage: O = L.equation_order()
     102            sage: I = O.ideal_with_gens_over_base([1, y]);  I
    64103            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    65104            sage: y in I
    66105            True
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    85124
    86125        EXAMPLES::
    87126
    88             sage: R.<x> = FunctionField(GF(7))
    89             sage: S = R.maximal_order(); S
     127            sage: K.<x> = FunctionField(GF(7))
     128            sage: O = K.maximal_order(); O
    90129            Maximal order in Rational function field in x over Finite Field of size 7
    91             sage: R.polynomial_ring()
     130            sage: K.polynomial_ring()
    92131            Univariate Polynomial Ring in x over Rational function field in x over Finite Field of size 7
    93             sage: I = S.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
     132            sage: I = O.ideal_with_gens_over_base([x^2 + 1, x*(x^2+1)])
    94133            sage: I.gens()
    95134            (x^2 + 1,)
    96135            sage: I.module()
    97136            Free module of degree 1 and rank 1 over Maximal order in Rational function field in x over Finite Field of size 7
    98137            User basis matrix:
    99138            [x^2 + 1]
    100             sage: V, from_V, to_V = R.vector_space(); V
     139            sage: V, from_V, to_V = K.vector_space(); V
    101140            Vector space of dimension 1 over Rational function field in x over Finite Field of size 7
    102141            sage: I.module().is_submodule(V)
    103142            True       
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    106145
    107146    def __add__(self, other):
    108147        """
    109         Add together two ideals.
     148        Add self and ``other``.
    110149       
    111150        EXAMPLES::
    112151       
    113             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    114             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    115             sage: I = M.ideal(y); J = M.ideal(y+1)
     152            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     153            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     154            sage: O = L.equation_order()
     155            sage: I = O.ideal(y); J = O.ideal(y+1)
    116156            sage: Z = I + J; Z
    117157            Ideal (y + 1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    118158            sage: 1 in Z
    119159            True
    120             sage: M.ideal(y^2) + M.ideal(y^3) == M.ideal(y^2,y^3)
     160            sage: O.ideal(y^2) + O.ideal(y^3) == O.ideal(y^2,y^3)
    121161            True
    122162        """
    123163        if not isinstance(other, FunctionFieldIdeal_module):
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    126166
    127167    def intersection(self, other):
    128168        """
    129         Return the intersection of the ideals self and other.
     169        Return the intersection of the ideals self and ``other``.
    130170       
    131171        EXAMPLES::
    132172
    133             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    134             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    135             sage: I = M.ideal(y^3); J = M.ideal(y^2)
     173            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     174            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     175            sage: O = L.equation_order()
     176            sage: I = O.ideal(y^3); J = O.ideal(y^2)
    136177            sage: Z = I.intersection(J); Z
    137178            Ideal (x^6 + 2*x^3 + 1, (6*x^3 + 6)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    138179            sage: y^2 in Z
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    148189
    149190    def __cmp__(self, other):
    150191        """
    151         Compare self and other.
     192        Compare self and ``other``.
    152193       
    153194        EXAMPLES::
    154195
    155             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    156             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    157             sage: M = L.equation_order()   
    158             sage: I = M.ideal(y*(y+1)); J = M.ideal((y^2-2)*(y+1))
     196            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     197            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     198            sage: O = L.equation_order()
     199            sage: I = O.ideal(y*(y+1)); J = O.ideal((y^2-2)*(y+1))
    159200            sage: I+J == J+I            # indirect test
    160201            True
    161202            sage: I == J
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    177218
    178219        EXAMPLES::
    179220
    180             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    181             sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    182             sage: I = M.ideal(y)
    183             sage: I.__invert__()
     221            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     222            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     223            sage: O = L.equation_order()
     224            sage: I = O.ideal(y)
     225            sage: ~I
    184226            Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    185227            sage: I^(-1)
    186228            Ideal (6, (1/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    187             sage: I.__invert__() * I
     229            sage: ~I * I
    188230            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    189231        """
    190232        if len(self.gens()) == 0:
    class FunctionFieldIdeal_module(FunctionFieldIdeal): 
    203245
    204246def ideal_with_gens(R, gens):
    205247    """
    206     Return fractional ideal in the order of R with given generators
    207     over R.
     248    Return fractional ideal in the order ``R`` with generators ``gens``
     249    over ``R``.
    208250
    209251    EXAMPLES::
    210252
    211         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    212         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    213         sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(M, [y])
     253        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     254        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     255        sage: O = L.equation_order()
     256        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(O, [y])
    214257        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
    215258    """
    216259    K = R.fraction_field()
    217260    return ideal_with_gens_over_base(R, [b*K(g) for b in R.basis() for g in gens])
    218    
    219261
    220262def ideal_with_gens_over_base(R, gens):
    221263    """
    222     Return fractional ideal in the given order R with given generators
     264    Return fractional ideal in the order ``R`` with generators ``gens``
    223265    over the maximal order of the base field.
    224266
    225267    EXAMPLES::
    226268
    227         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    228         sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    229         sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(M, [x^3+1,-y])
     269        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     270        sage: L.<y> = K.extension(y^2 - x^3 - 1)
     271        sage: O = L.equation_order()
     272        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(O, [x^3+1,-y])
    230273        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1   
    231274   
    232275    TESTS::
     276
    233277        sage: K.<x> = FunctionField(QQ)
    234278        sage: O = K.maximal_order()
    235279        sage: I = O*x
    def ideal_with_gens_over_base(R, gens): 
    237281        Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
    238282        sage: ~I == O.ideal(1/x)
    239283        True
    240    
     284        sage: O.ideal([x,1/x])
     285        Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     286        sage: O.ideal([1/x,1/(x+1)])
     287        Ideal (1/(x^2 + x)) of Maximal order in Rational function field in x over Rational Field
    241288    """
    242289    K = R.fraction_field()
    243290    V, from_V, to_V = K.vector_space()
  • sage/rings/function_field/function_field_order.py

    diff --git a/sage/rings/function_field/function_field_order.py b/sage/rings/function_field/function_field_order.py
    index 46a47e1..bca4570 100644
    a b  
    1 """
    2 Orders in Function Fields
     1r"""
     2Orders in Function Fields.
     3
     4EXAMPLES:
     5
     6Maximal orders in rational function fields::
     7
     8    sage: K.<x> = FunctionField(QQ)
     9    sage: O = K.maximal_order()
     10    sage: I = O.ideal(1/x); I
     11    Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     12    sage: 1/x in O
     13    False
     14
     15Equation orders in extensions of rational function fields::
     16
     17    sage: K.<x> = FunctionField(GF(3)); R.<y> = K[]
     18    sage: L.<y> = K.extension(y^3-y-x)
     19    sage: O = L.equation_order()
     20    sage: 1/y in O
     21    False
     22    sage: x/y in O
     23    True
    324"""
    425
    526from sage.structure.parent_gens import ParentWithGens
    from sage.rings.ring import IntegralDomain, PrincipalIdealDomain 
    930from sage.rings.ideal import is_Ideal
    1031
    1132class FunctionFieldOrder(IntegralDomain):
     33    """
     34    Base class for orders in function fields.
     35    """
    1236    def __init__(self, fraction_field):
    1337        """
     38        INPUT::
     39
     40            - ``fraction_field`` -- the function field in which this iss an order.
     41
    1442        EXAMPLES::
    1543
    1644            sage: R = FunctionField(QQ,'y').maximal_order()
    class FunctionFieldOrder(IntegralDomain): 
    3159
    3260    def is_finite(self):
    3361        """
     62        Returns False since orders are never finite.
     63
    3464        EXAMPLES::
    3565
    3666            sage: FunctionField(QQ,'y').maximal_order().is_finite()
    class FunctionFieldOrder(IntegralDomain): 
    4070
    4171    def is_field(self, proof=True):
    4272        """
     73        Returns False since orders are never fields.
     74
    4375        EXAMPLES::
    4476
    4577            sage: FunctionField(QQ,'y').maximal_order().is_field()
    class FunctionFieldOrder(IntegralDomain): 
    4981
    5082    def is_noetherian(self):
    5183        """
    52         Return True, since orders in function fields are noetherian.
     84        Returns True since orders in function fields are noetherian.
    5385       
    5486        EXAMPLES::
    5587
    class FunctionFieldOrder(IntegralDomain): 
    6092
    6193    def fraction_field(self):
    6294        """
    63         Returns the function field in wich this is an order
     95        Returns the function field in which this is an order.
    6496
    6597        EXAMPLES::
    6698
    class FunctionFieldOrder(IntegralDomain): 
    73105   
    74106    def ideal_with_gens_over_base(self, gens):
    75107        """
    76         Return the fractional ideal with given generators over the
    77         maximal ideal of the base field. That this is really an ideal
     108        Returns the fractional ideal with basis ``gens`` over the
     109        maximal order of the base field. That this is really an ideal
    78110        is not checked.
    79111
    80112        INPUT:
    81113
    82             - ``basis`` -- list of elements that are a basis for the
     114            - ``gens`` -- list of elements that are a basis for the
    83115              ideal over the maximal order of the base field
    84116           
    85117        EXAMPLES::
    86118
    87119        We construct an ideal in a rational function field::
    88120       
    89             sage: R.<y> = FunctionField(QQ)
    90             sage: S = R.maximal_order()
    91             sage: I = S.ideal_with_gens_over_base([y]); I
     121            sage: K.<y> = FunctionField(QQ)
     122            sage: O = K.maximal_order()
     123            sage: I = O.ideal_with_gens_over_base([y]); I
    92124            Ideal (y) of Maximal order in Rational function field in y over Rational Field
    93125            sage: I*I
    94126            Ideal (y^2) of Maximal order in Rational function field in y over Rational Field
    95127
    96128        We construct some ideals in a nontrivial function field::
    97129
    98             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    99             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    100             sage: M = L.equation_order(); M
     130            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     131            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     132            sage: O = L.equation_order(); O
    101133            Order in Function field in y defined by y^2 + 6*x^3 + 6
    102             sage: I = M.ideal_with_gens_over_base([1, y]);  I
     134            sage: I = O.ideal_with_gens_over_base([1, y]);  I
    103135            Ideal (1, y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    104136            sage: I.module()
    105137            Free module of degree 2 and rank 2 over Maximal order in Rational function field in x over Finite Field of size 7
    106138            Echelon basis matrix:
    107139            [1 0]
    108140            [0 1]
     141
     142        There is no check if the resulting object is really an ideal::
     143
     144            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     145            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     146            sage: O = L.equation_order()
     147            sage: I = O.ideal_with_gens_over_base([y]); I
     148            Ideal (y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
     149            sage: y in I
     150            True
     151            sage: y^2 in I
     152            False
    109153        """
    110154        from function_field_ideal import ideal_with_gens_over_base
    111155        return ideal_with_gens_over_base(self, [self(a) for a in gens])
    112156
    113157    def ideal(self, *gens):
    114158        """
    115         Return the fractional ideal generated by the element gens or
    116         the elements in gens if gens is a list.
     159        Returns the fractional ideal generated by the elements in ``gens``.
     160
     161        INPUT:
     162
     163            - ``gens`` -- a list of generators
    117164
    118165        EXAMPLES::
    119166
    120             sage: R.<y> = FunctionField(QQ)
    121             sage: S = R.maximal_order()
    122             sage: S.ideal(y)
     167            sage: K.<y> = FunctionField(QQ)
     168            sage: O = K.maximal_order()
     169            sage: O.ideal(y)
    123170            Ideal (y) of Maximal order in Rational function field in y over Rational Field
     171            sage: O.ideal([y,1/y]) == O.ideal(y,1/y) # multiple generators may be given as a list
     172            True
    124173
    125174        A fractional ideal of a nontrivial extension::
    126175
    127             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    128             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    129             sage: M = L.equation_order()
    130             sage: M.ideal(1/y)
     176            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     177            sage: L.<y> = K.extension(y^2 - x^3 - 1)
     178            sage: O = L.equation_order()
     179            sage: O.ideal(1/y)
    131180            Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6       
    132181        """
    133182        if len(gens) == 1:
    class FunctionFieldOrder_basis(FunctionFieldOrder): 
    150199        """
    151200        EXAMPLES::
    152201
    153             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()
    154             sage: S
    155             Order in Function field in Y defined by y^4 + x*y + 4*x + 1
    156             sage: type(S)
     202            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     203            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     204            sage: O = L.equation_order(); O
     205            Order in Function field in y defined by y^4 + x*y + 4*x + 1
     206            sage: type(O)
    157207            <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis_with_category'>
    158208
    159209        The basis only defines an order if the module it generates is closed under multiplication
    160          and contains the identity element. This is only checked when check=True ::
     210         and contains the identity element (only checked when ``check`` is True)::
    161211
    162212            sage: K.<x> = FunctionField(QQ)
    163213            sage: R.<y> = K[]
    164             sage: L.<w> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));
    165             sage: w.is_integral()
     214            sage: L.<y> = K.extension(y^5 - (x^3 + 2*x*y + 1/x));
     215            sage: y.is_integral()
    166216            False
    167             sage: L.order(w)
     217            sage: L.order(y)
    168218            Traceback (most recent call last):
    169219            ...
    170             ValueError: The module generated by basis [1, w, w^2, w^3, w^4] must be closed under multiplication
     220            ValueError: The module generated by basis [1, y, y^2, y^3, y^4] must be closed under multiplication
    171221           
    172         The basis also has to be linear independent and of the same rank as the degree of the function field of it's elements::
     222        The basis also has to be linearly independent and of the same rank as the degree of the function field of its elements (only checked when ``check`` is True)::
    173223
    174224            sage: L.order(L(x))
    175225            Traceback (most recent call last):
    176226            ...
    177             ValueError: Basis [1, x, x^2, x^3, x^4] is not linear independent
    178             sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([w,w,w^3,w^4,w^5])
     227            ValueError: Basis [1, x, x^2, x^3, x^4] is not linearly independent
     228            sage: sage.rings.function_field.function_field_order.FunctionFieldOrder_basis([y,y,y^3,y^4,y^5])
    179229            Traceback (most recent call last):
    180230            ...
    181             ValueError: Basis [w, w, w^3, w^4, 2*x*w + (x^4 + 1)/x] is not linear independent
    182        
    183 
     231            ValueError: Basis [y, y, y^3, y^4, 2*x*y + (x^4 + 1)/x] is not linearly independent
    184232        """
    185233        if len(basis) == 0:
    186234            raise ValueError, "basis must have positive length"
    class FunctionFieldOrder_basis(FunctionFieldOrder): 
    199247        self._populate_coercion_lists_(coerce_list=[self._ring])
    200248        if check:
    201249            if self._module.rank() != fraction_field.degree():
    202                 raise ValueError, "Basis %s is not linear independent"%(basis)
     250                raise ValueError, "Basis %s is not linearly independent"%(basis)
    203251            if not to(fraction_field(1)) in self._module:
    204252                raise ValueError, "The identity element must be in the module spanned by basis %s"%(basis)
    205253            if not all(to(a*b) in self._module for a in basis for b in basis):
    class FunctionFieldOrder_basis(FunctionFieldOrder): 
    208256
    209257    def _element_constructor_(self, f, check=True):
    210258        """
     259        Make ``f`` into an element of this order.
     260
     261        INPUT::
     262
     263            - ``f`` -- the element
     264            - ``check`` -- check if the element is in the order
     265
    211266        EXAMPLES::
    212267
    213             sage: R.<y> = FunctionField(QQ)
    214             sage: R.maximal_order()._element_constructor_(y)
    215             y
    216        
    217         If check=True test if the element is indeed in the order.
     268            sage: K.<x> = FunctionField(QQ)
     269            sage: K.maximal_order()._element_constructor_(x)
     270            x
    218271        """
    219272        fraction_field=self.fraction_field()
    220273       
    class FunctionFieldOrder_basis(FunctionFieldOrder): 
    230283
    231284    def fraction_field(self):
    232285        """
     286        Returns the function field in which this is an order.
     287
    233288        EXAMPLES::
    234289
    235             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    236             sage: S.fraction_field()
    237             Function field in Y defined by y^4 + x*y + 4*x + 1
     290            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     291            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     292            sage: O = L.equation_order()
     293            sage: O.fraction_field()
     294            Function field in y defined by y^4 + x*y + 4*x + 1
    238295        """
    239296        return self._fraction_field
    240297
    class FunctionFieldOrder_basis(FunctionFieldOrder): 
    244301       
    245302        EXAMPLES::
    246303
    247             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    248             sage: S.polynomial()
     304            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     305            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     306            sage: O = L.equation_order()
     307            sage: O.polynomial()
    249308            y^4 + x*y + 4*x + 1
    250        
    251309        """
    252310        return self._fraction_field.polynomial()
    253311
    254 
    255312    def basis(self):
    256313        """
     314        Returns a basis of self over the maximal order of the base field.
     315
    257316        EXAMPLES::
    258317
    259             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()           
    260             sage: S.basis()
    261             (1, Y, Y^2, Y^3)
     318            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     319            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     320            sage: O = L.equation_order()
     321            sage: O.basis()
     322            (1, y, y^2, y^3)
    262323        """
    263324        return self._basis
    264325
    265326    def free_module(self):
    266327        """
     328        Returns the free module formed by the basis over the maximal order of the base field.
     329
    267330        EXAMPLES::
    268331
    269             sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order()
    270             sage: S.free_module()
     332            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     333            sage: L.<y> = K.extension(y^4 + x*y + 4*x + 1)
     334            sage: O = L.equation_order()
     335            sage: O.free_module()
    271336            Free module of degree 4 and rank 4 over Maximal order in Rational function field in x over Finite Field of size 7
    272337            Echelon basis matrix:
    273338            [1 0 0 0]
    class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder): 
    312377
    313378    def basis(self):
    314379        """
    315         Return basis (=1) for this order as a module over the polynomial ring.
     380        Returns the basis (=1) for this order as a module over the polynomial ring.
    316381       
    317382        EXAMPLES::
    318383
    319384            sage: K.<t> = FunctionField(GF(19))
    320             sage: M = K.maximal_order()
    321             sage: M.basis()
     385            sage: O = K.maximal_order()
     386            sage: O.basis()
    322387            (1,)
    323             sage: parent(M.basis()[0])
     388            sage: parent(O.basis()[0])
    324389            Maximal order in Rational function field in t over Finite Field of size 19
    325390        """
    326391        return self._basis
    327392
    328393    def ideal(self, *gens):
    329394        """
    330         Return the fractional ideal generated by the element gens or
    331         the elements in gens if gens is a list.
     395        Returns the fractional ideal generated by ``gens``.
    332396
    333397        EXAMPLES::
    334398
    335             sage: R.<y> = FunctionField(QQ)
    336             sage: S = R.maximal_order()
    337             sage: S.ideal(y)
    338             Ideal (y) of Maximal order in Rational function field in y over Rational Field
    339 
    340         A fractional ideal of a nontrivial extension::
    341 
    342             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    343             sage: L.<y> = R.extension(y^2 - x^3 - 1)
    344             sage: M = L.equation_order()
    345             sage: M.ideal(1/y)
    346             Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    347 
    348         A non-principal ideal::
    349 
    350             sage: R.<x> = FunctionField(GF(7))
    351             sage: S = R.maximal_order()
    352             sage: S.ideal(x^3+1,x^3+6)
    353             Ideal (1) of Maximal order in Rational function field in x over Finite Field of size 7
    354             sage: S.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1))
    355             Ideal (x^2 + 1) of Maximal order in Rational function field in x over Finite Field of size 7   
     399            sage: K.<x> = FunctionField(QQ)
     400            sage: O = K.maximal_order()
     401            sage: O.ideal(x)
     402            Ideal (x) of Maximal order in Rational function field in x over Rational Field
     403            sage: O.ideal([x,1/x]) == O.ideal(x,1/x) # multiple generators may be given as a list
     404            True
     405            sage: O.ideal(x^3+1,x^3+6)
     406            Ideal (1) of Maximal order in Rational function field in x over Rational Field
     407            sage: O.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1))
     408            Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
    356409        """
    357410        if len(gens) == 1:
    358411            gens = gens[0]
    359412            if not isinstance(gens, (list, tuple)):
    360                 if is_Ideal(gens):
    361                     gens = gens.gens()
    362                 else:
    363                     gens = [gens]
     413                gens = (gens,)
    364414        from function_field_ideal import ideal_with_gens
    365415        return ideal_with_gens(self, gens)
    366416
    class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder): 
    375425
    376426    def gen(self, n=0):
    377427        """
     428        Returns the ``n``-th generator of self. Since there is only one generator ``n`` must be 0.
     429
    378430        EXAMPLES::
    379431
    380             sage: R = FunctionField(QQ,'y').maximal_order(); R.gen()
     432            sage: O = FunctionField(QQ,'y').maximal_order()
     433            sage: O.gen()
    381434            y
    382             sage: R.gen(1)
     435            sage: O.gen(1)
    383436            Traceback (most recent call last):
    384437            ...
    385438            IndexError: Only one generator.
    class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder): 
    389442
    390443    def ngens(self):
    391444        """
     445        Returns 1, the number of generators of self.
     446
    392447        EXAMPLES::
    393448
    394             sage: R = FunctionField(QQ,'y').maximal_order(); R.ngens()
     449            sage: FunctionField(QQ,'y').maximal_order().ngens()
    395450            1
    396451        """
    397452        return 1
    398453
    399454    def _element_constructor_(self, f):
    400455        """
     456        Make ``f`` into an element of this order.
     457
    401458        EXAMPLES::
    402459
    403             sage: R.<y> = FunctionField(QQ)
    404             sage: R.maximal_order()._element_constructor_(y)
     460            sage: K.<y> = FunctionField(QQ)
     461            sage: O = K.maximal_order()
     462            sage: O._element_constructor_(y)
    405463            y
     464            sage: O._element_constructor_(1/y)
     465            Traceback (most recent call last):
     466            ...
     467            ValueError: `1/y` is not a member of `Maximal order in Rational function field in y over Rational Field`
    406468        """
    407469        if f.parent() is self.fraction_field():
    408470            if not f.denominator() in self.fraction_field().constant_base_field():
  • sage/rings/function_field/maps.py

    diff --git a/sage/rings/function_field/maps.py b/sage/rings/function_field/maps.py
    index 64d998b..ef523b2 100644
    a b  
    11r"""
    2 
     2Function field morphisms.
     3
     4EXAMPLES::
     5
     6    sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     7    sage: K.hom(1/x)
     8    Morphism of function fields defined by x |--> 1/x
     9    sage: L.<y> = K.extension(y^2-x)
     10    sage: K.hom(y)
     11    Morphism of function fields defined by x |--> y
     12    sage: L.hom([y,x])
     13    Morphism of function fields defined by y |--> y,  x |--> x
     14    sage: L.hom([x,y])
     15    Traceback (most recent call last):
     16    ...
     17    ValueError: invalid morphism
    318"""
    419
    520from sage.categories.morphism import Morphism
    class FunctionFieldIsomorphism(Morphism): 
    1530
    1631    EXAMPLES::
    1732
    18         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     33        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     34        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    1935        sage: V, f, t = L.vector_space()
    2036        sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldIsomorphism)
    2137        True
    class FunctionFieldIsomorphism(Morphism): 
    2642       
    2743        EXAMPLES::
    2844
    29             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     45            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     46            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    3047            sage: V, f, t = L.vector_space()
    3148            sage: f._repr_type()
    3249            'Isomorphism'
    class FunctionFieldIsomorphism(Morphism): 
    3956       
    4057        EXAMPLES::
    4158
    42             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     59            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     60            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    4361            sage: V, f, t = L.vector_space()           
    4462            sage: f.is_injective()
    4563            True
    class FunctionFieldIsomorphism(Morphism): 
    5270       
    5371        EXAMPLES::
    5472
    55             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     73            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     74            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    5675            sage: V, f, t = L.vector_space()           
    5776            sage: f.is_surjective()
    5877            True
    class FunctionFieldIsomorphism(Morphism): 
    6180
    6281class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism):
    6382    r"""
    64     An isomorphism from a vector space and a function field.
     83    An isomorphism from a vector space to a function field.
    6584   
    6685    EXAMPLES:
    6786
    68         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     87        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     88        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    6989        sage: V, f, t = L.vector_space(); f
    7090        Isomorphism morphism:
    7191          From: Vector space of dimension 2 over Rational function field in x over Rational Field
    72           To:   Function field in Y defined by y^2 - x*y + 4*x^3
     92          To:   Function field in y defined by y^2 - x*y + 4*x^3
    7393    """
    7494    def __init__(self, V, K):
    7595        """
    7696        EXAMPLES::
    7797       
    78             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     98            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     99            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    79100            sage: V, f, t = L.vector_space(); type(f)
    80101            <class 'sage.rings.function_field.maps.MapVectorSpaceToFunctionField'>
    81102        """
    class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism): 
    88109        """
    89110        EXAMPLES::
    90111
    91             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     112            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     113            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    92114            sage: V, f, t = L.vector_space()                       
    93115            sage: f(x*V.0 + (1/x^3)*V.1)         # indirect doctest
    94             1/x^3*Y + x
     116            1/x^3*y + x
    95117        """
    96118        f = self._R(self._V(v).list())
    97119        return self._K(f)
    98120
    99121    def domain(self):
    100122        """
     123        Return the vector space which is the domain of this isomorphism.
     124
    101125        EXAMPLES::
    102126
    103             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     127            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     128            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    104129            sage: V, f, t = L.vector_space()                                   
    105130            sage: f.domain()
    106131            Vector space of dimension 2 over Rational function field in x over Rational Field
    class MapVectorSpaceToFunctionField(FunctionFieldIsomorphism): 
    109134
    110135    def codomain(self):
    111136        """
     137        Return the function field which is the codomain of this isomorphism.
     138
    112139        EXAMPLES::
    113140
    114             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     141            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     142            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    115143            sage: V, f, t = L.vector_space()                                   
    116144            sage: f.codomain()
    117             Function field in Y defined by y^2 - x*y + 4*x^3
     145            Function field in y defined by y^2 - x*y + 4*x^3
    118146        """
    119147        return self._K
    120148
    121 
    122149class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism):
    123150    """
    124151    An isomorphism from a function field to a vector space.
    125152   
    126153    EXAMPLES::
    127154
    128         sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     155        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     156        sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    129157        sage: V, f, t = L.vector_space(); t
    130158        Isomorphism morphism:
    131           From: Function field in Y defined by y^2 - x*y + 4*x^3
     159          From: Function field in y defined by y^2 - x*y + 4*x^3
    132160          To:   Vector space of dimension 2 over Rational function field in x over Rational Field
    133161    """
    134162    def __init__(self, K, V):
    135163        """
    136164        EXAMPLES::
    137165
    138             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     166            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     167            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    139168            sage: V, f, t = L.vector_space(); type(t)
    140169            <class 'sage.rings.function_field.maps.MapFunctionFieldToVectorSpace'>
    141170        """
    class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism): 
    147176
    148177    def domain(self):
    149178        """
     179        Return the function field which is the domain of this isomorphism.
     180
    150181        EXAMPLES::
    151182
    152             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     183            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     184            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    153185            sage: V, f, t = L.vector_space()                                   
    154186            sage: t.domain()
    155             Function field in Y defined by y^2 - x*y + 4*x^3
     187            Function field in y defined by y^2 - x*y + 4*x^3
    156188        """
    157189        return self._K
    158190
    159191    def codomain(self):
    160192        """
     193        Return the vector space which is the domain of this isomorphism.
     194
    161195        EXAMPLES::
    162196
    163             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     197            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     198            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    164199            sage: V, f, t = L.vector_space()                                   
    165200            sage: t.codomain()
    166201            Vector space of dimension 2 over Rational function field in x over Rational Field       
    class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism): 
    171206        """
    172207        EXAMPLES::
    173208
    174             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     209            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     210            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    175211            sage: V, f, t = L.vector_space()
    176212            sage: t._repr_type()
    177213            'Isomorphism'
    class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism): 
    182218        """
    183219        EXAMPLES::
    184220
    185             sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2 - x*y + 4*x^3)
     221            sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     222            sage: L.<y> = K.extension(y^2 - x*y + 4*x^3)
    186223            sage: V, f, t = L.vector_space()                                   
    187             sage: t(x + (1/x^3)*Y)                       # indirect doctest
     224            sage: t(x + (1/x^3)*y)                       # indirect doctest
    188225            (x, 1/x^3)
    189226        """
    190227        y = self._K(x)
    class MapFunctionFieldToVectorSpace(FunctionFieldIsomorphism): 
    193230        return self._V(w)
    194231
    195232class FunctionFieldMorphism(RingHomomorphism):
     233    r"""
     234    Base class for morphisms between function fields.
     235    """
    196236    def __init__(self, parent, im_gen, base_morphism):
     237        """
     238        EXAMPLES::
     239
     240            sage: K.<x> = FunctionField(QQ)
     241            sage: f = K.hom(1/x); f
     242            Morphism of function fields defined by x |--> 1/x
     243            sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldMorphism)
     244            True
     245        """
    197246        RingHomomorphism.__init__(self, parent)
    198247
    199248        self._im_gen = im_gen
    class FunctionFieldMorphism(RingHomomorphism): 
    205254
    206255        EXAMPLES::
    207256
    208             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    209             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
     257            sage: K.<x> = FunctionField(QQ)
     258            sage: f = K.hom(1/x); f
     259            Morphism of function fields defined by x |--> 1/x
    210260            sage: f.is_injective()
    211261            True
    212262        """
    class FunctionFieldMorphism(RingHomomorphism): 
    216266        """
    217267        EXAMPLES::
    218268
    219             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    220             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
     269            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     270            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     271            sage: f = L.hom(y*2)
    221272            sage: f.__repr__()     
    222273            'Morphism of function fields defined by y |--> 2*y'
    223274        """
    class FunctionFieldMorphism(RingHomomorphism): 
    227278        """
    228279        EXAMPLES::
    229280
    230             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    231             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
     281            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     282            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     283            sage: f = L.hom(y*2)
    232284            sage: f._short_repr()
    233285            'y |--> 2*y'
    234286        """
    class FunctionFieldMorphism(RingHomomorphism): 
    239291
    240292class FunctionFieldMorphism_polymod(FunctionFieldMorphism):
    241293    """
     294    Morphism from a finite extension of a function field to a function field.
     295
    242296    EXAMPLES::
    243297
    244         sage: R.<x> = FunctionField(QQ); S.<y> = R[]
    245         sage: L.<y> = R.extension(y^2 - x^2)
     298        sage: K.<x> = FunctionField(QQ); R.<y> = K[]
     299        sage: L.<y> = K.extension(y^2 - x)
    246300        sage: f = L.hom(-y); f
    247301        Morphism of function fields defined by y |--> -y   
    248302    """
    class FunctionFieldMorphism_polymod(FunctionFieldMorphism): 
    250304        """
    251305        EXAMPLES::
    252306
    253             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    254             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2); f
     307            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     308            sage: L.<y> = K.extension(y^3 + 6*x^3 + x)
     309            sage: f = L.hom(y*2); f
    255310            Morphism of function fields defined by y |--> 2*y
    256311            sage: type(f)
    257312            <class 'sage.rings.function_field.maps.FunctionFieldMorphism_polymod'>
    class FunctionFieldMorphism_polymod(FunctionFieldMorphism): 
    274329        """
    275330        EXAMPLES::
    276331
    277             sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
    278             sage: L.<y> = R.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
     332            sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
     333            sage: L.<y> = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2)
    279334            sage: f(y/x + x^2/(x+1))            # indirect doctest
    280335            2/x*y + x^2/(x + 1)
    281336            sage: f(y)
    class FunctionFieldMorphism_polymod(FunctionFieldMorphism): 
    288343        return f(self._im_gen)
    289344
    290345class FunctionFieldMorphism_rational(FunctionFieldMorphism):
     346    """
     347    Morphism from a rational function field to a function field.
     348
     349    EXAMPLES::
     350
     351        sage: K.<x> = FunctionField(QQ)
     352        sage: f = K.hom(1/x); f
     353        Morphism of function fields defined by x |--> 1/x
     354    """
    291355    def __init__(self, parent, im_gen):
    292356        """
    293357        EXAMPLES::
    294358
    295             sage: R.<x> = FunctionField(GF(7)); f = R.hom(1/x); f
     359            sage: K.<x> = FunctionField(GF(7))
     360            sage: f = K.hom(1/x); f
    296361            Morphism of function fields defined by x |--> 1/x
    297362            sage: type(f)
    298363            <class 'sage.rings.function_field.maps.FunctionFieldMorphism_rational'>
    class FunctionFieldMorphism_rational(FunctionFieldMorphism): 
    303368        """
    304369        EXAMPLES::
    305370
    306             sage: R.<x> = FunctionField(GF(7)); f = R.hom(1/x); f
     371            sage: K.<x> = FunctionField(GF(7))
     372            sage: f = K.hom(1/x); f
    307373            Morphism of function fields defined by x |--> 1/x
    308374            sage: f(x+1)                          # indirect doctest
    309375            (x + 1)/x