Univariate rational functions over prime fields - Polynomials

Skip to content
Back to top
View this page
Edit this page

# Univariate rational functions over prime fields

class sage.rings.fraction_field_FpT.FpT(R, names=None)

  Bases: `FractionField_1poly_field`

  This class represents the fraction field \(\GF{p}(T)\) for \(2 < p < \sqrt{2^{31}-1}\).

  EXAMPLES:

  Sage

      sage: R.<T> = GF(71)[]
      sage: K = FractionField(R); K
      Fraction Field of Univariate Polynomial Ring in T over Finite Field of size 71
      sage: 1-1/T
      (T + 70)/T
      sage: parent(1-1/T) is K
      True

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(71))['T']; (T,) = R._first_ngens(1)
      >>> K = FractionField(R); K
      Fraction Field of Univariate Polynomial Ring in T over Finite Field of size 71
      >>> Integer(1)-Integer(1)/T
      (T + 70)/T
      >>> parent(Integer(1)-Integer(1)/T) is K
      True

  INTEGER_LIMIT = 46341
  iter(bound=None, start=None)

    EXAMPLES:

    Sage

        sage: from sage.rings.fraction_field_FpT import *
        sage: R.<t> = FpT(GF(5)['t'])
        sage: list(R.iter(2))[350:355]
        [(t^2 + t + 1)/(t + 2),
         (t^2 + t + 2)/(t + 2),
         (t^2 + t + 4)/(t + 2),
         (t^2 + 2*t + 1)/(t + 2),
         (t^2 + 2*t + 2)/(t + 2)]

    Python

        >>> from sage.all import *
        >>> from sage.rings.fraction_field_FpT import *
        >>> R = FpT(GF(Integer(5))['t'], names=('t',)); (t,) = R._first_ngens(1)
        >>> list(R.iter(Integer(2)))[Integer(350):Integer(355)]
        [(t^2 + t + 1)/(t + 2),
         (t^2 + t + 2)/(t + 2),
         (t^2 + t + 4)/(t + 2),
         (t^2 + 2*t + 1)/(t + 2),
         (t^2 + 2*t + 2)/(t + 2)]

class sage.rings.fraction_field_FpT.FpTElement

  Bases: `FieldElement`

  An element of an `FpT` fraction field.

  denom()

    Return the denominator of this element, as an element of the polynomial ring.

    EXAMPLES:

    Sage

        sage: K = GF(11)['t'].fraction_field()
        sage: t = K.gen(0); a = (t + 1/t)^3 - 1
        sage: a.denom()
        t^3

    Python

        >>> from sage.all import *
        >>> K = GF(Integer(11))['t'].fraction_field()
        >>> t = K.gen(Integer(0)); a = (t + Integer(1)/t)**Integer(3) - Integer(1)
        >>> a.denom()
        t^3

  denominator()

    Return the denominator of this element, as an element of the polynomial ring.

    EXAMPLES:

    Sage

        sage: K = GF(11)['t'].fraction_field()
        sage: t = K.gen(0); a = (t + 1/t)^3 - 1
        sage: a.denominator()
        t^3

    Python

        >>> from sage.all import *
        >>> K = GF(Integer(11))['t'].fraction_field()
        >>> t = K.gen(Integer(0)); a = (t + Integer(1)/t)**Integer(3) - Integer(1)
        >>> a.denominator()
        t^3

  factor()

    EXAMPLES:

    Sage

        sage: K = Frac(GF(5)['t'])
        sage: t = K.gen()
        sage: f = 2 * (t+1) * (t^2+t+1)^2 / (t-1)
        sage: factor(f)
        (2) * (t + 4)^-1 * (t + 1) * (t^2 + t + 1)^2

    Python

        >>> from sage.all import *
        >>> K = Frac(GF(Integer(5))['t'])
        >>> t = K.gen()
        >>> f = Integer(2) * (t+Integer(1)) * (t**Integer(2)+t+Integer(1))**Integer(2) / (t-Integer(1))
        >>> factor(f)
        (2) * (t + 4)^-1 * (t + 1) * (t^2 + t + 1)^2

  is_square()

    Return `True` if this element is the square of another element of the fraction field.

    EXAMPLES:

    Sage

        sage: K = GF(13)['t'].fraction_field(); t = K.gen()
        sage: t.is_square()
        False
        sage: (1/t^2).is_square()
        True
        sage: K(0).is_square()
        True

    Python

        >>> from sage.all import *
        >>> K = GF(Integer(13))['t'].fraction_field(); t = K.gen()
        >>> t.is_square()
        False
        >>> (Integer(1)/t**Integer(2)).is_square()
        True
        >>> K(Integer(0)).is_square()
        True

  next()

    Iterate through all polynomials, returning the “next” polynomial after this one.

    The strategy is as follows:

    - We always leave the denominator monic.

    - We progress through the elements with both numerator and denominator monic, and with the denominator less than the numerator. For each such, we output all the scalar multiples of it, then all of the scalar multiples of its inverse.

    - So if the leading coefficient of the numerator is less than \(p-1\), we scale the numerator to increase it by 1.

    - Otherwise, we consider the multiple with numerator and denominator monic.

      - If the numerator is less than the denominator (lexicographically), we return the inverse of that element.

      - If the numerator is greater than the denominator, we invert, and then increase the numerator (remaining monic) until we either get something relatively prime to the new denominator, or we reach the new denominator. In this case, we increase the denominator and set the numerator to 1.

    EXAMPLES:

    Sage

        sage: from sage.rings.fraction_field_FpT import *
        sage: R.<t> = FpT(GF(3)['t'])
        sage: a = R(0)
        sage: for _ in range(30):
        ....:     a = a.next()
        ....:     print(a)
        1
        2
        1/t
        2/t
        t
        2*t
        1/(t + 1)
        2/(t + 1)
        t + 1
        2*t + 2
        t/(t + 1)
        2*t/(t + 1)
        (t + 1)/t
        (2*t + 2)/t
        1/(t + 2)
        2/(t + 2)
        t + 2
        2*t + 1
        t/(t + 2)
        2*t/(t + 2)
        (t + 2)/t
        (2*t + 1)/t
        (t + 1)/(t + 2)
        (2*t + 2)/(t + 2)
        (t + 2)/(t + 1)
        (2*t + 1)/(t + 1)
        1/t^2
        2/t^2
        t^2
        2*t^2

    Python

        >>> from sage.all import *
        >>> from sage.rings.fraction_field_FpT import *
        >>> R = FpT(GF(Integer(3))['t'], names=('t',)); (t,) = R._first_ngens(1)
        >>> a = R(Integer(0))
        >>> for _ in range(Integer(30)):
        ...     a = a.next()
        ...     print(a)
        1
        2
        1/t
        2/t
        t
        2*t
        1/(t + 1)
        2/(t + 1)
        t + 1
        2*t + 2
        t/(t + 1)
        2*t/(t + 1)
        (t + 1)/t
        (2*t + 2)/t
        1/(t + 2)
        2/(t + 2)
        t + 2
        2*t + 1
        t/(t + 2)
        2*t/(t + 2)
        (t + 2)/t
        (2*t + 1)/t
        (t + 1)/(t + 2)
        (2*t + 2)/(t + 2)
        (t + 2)/(t + 1)
        (2*t + 1)/(t + 1)
        1/t^2
        2/t^2
        t^2
        2*t^2

  numer()

    Return the numerator of this element, as an element of the polynomial ring.

    EXAMPLES:

    Sage

        sage: K = GF(11)['t'].fraction_field()
        sage: t = K.gen(0); a = (t + 1/t)^3 - 1
        sage: a.numer()
        t^6 + 3*t^4 + 10*t^3 + 3*t^2 + 1

    Python

        >>> from sage.all import *
        >>> K = GF(Integer(11))['t'].fraction_field()
        >>> t = K.gen(Integer(0)); a = (t + Integer(1)/t)**Integer(3) - Integer(1)
        >>> a.numer()
        t^6 + 3*t^4 + 10*t^3 + 3*t^2 + 1

  numerator()

    Return the numerator of this element, as an element of the polynomial ring.

    EXAMPLES:

    Sage

        sage: K = GF(11)['t'].fraction_field()
        sage: t = K.gen(0); a = (t + 1/t)^3 - 1
        sage: a.numerator()
        t^6 + 3*t^4 + 10*t^3 + 3*t^2 + 1

    Python

        >>> from sage.all import *
        >>> K = GF(Integer(11))['t'].fraction_field()
        >>> t = K.gen(Integer(0)); a = (t + Integer(1)/t)**Integer(3) - Integer(1)
        >>> a.numerator()
        t^6 + 3*t^4 + 10*t^3 + 3*t^2 + 1

  sqrt(extend=True, all=False)

    Return the square root of this element.

    INPUT:

    - `extend` – boolean (default: `True`); if `True`, return a square root in an extension ring, if necessary. Otherwise, raise a `ValueError` if the square is not in the base ring.

    - `all` – boolean (default: `False`); if `True`, return all square roots of self, instead of just one

    EXAMPLES:

    Sage

        sage: from sage.rings.fraction_field_FpT import *
        sage: K = GF(7)['t'].fraction_field(); t = K.gen(0)
        sage: p = (t + 2)^2/(3*t^3 + 1)^4
        sage: p.sqrt()
        (3*t + 6)/(t^6 + 3*t^3 + 4)
        sage: p.sqrt()^2 == p
        True

    Python

        >>> from sage.all import *
        >>> from sage.rings.fraction_field_FpT import *
        >>> K = GF(Integer(7))['t'].fraction_field(); t = K.gen(Integer(0))
        >>> p = (t + Integer(2))**Integer(2)/(Integer(3)*t**Integer(3) + Integer(1))**Integer(4)
        >>> p.sqrt()
        (3*t + 6)/(t^6 + 3*t^3 + 4)
        >>> p.sqrt()**Integer(2) == p
        True

  subs(in_dict=None, *args, **kwds)

    EXAMPLES:

    Sage

        sage: K = Frac(GF(11)['t'])
        sage: t = K.gen()
        sage: f = (t+1)/(t-1)
        sage: f.subs(t=2)
        3
        sage: f.subs(X=2)
        (t + 1)/(t + 10)

    Python

        >>> from sage.all import *
        >>> K = Frac(GF(Integer(11))['t'])
        >>> t = K.gen()
        >>> f = (t+Integer(1))/(t-Integer(1))
        >>> f.subs(t=Integer(2))
        3
        >>> f.subs(X=Integer(2))
        (t + 1)/(t + 10)

  valuation(v)

    Return the valuation of `self` at \(v\).

    EXAMPLES:

    Sage

        sage: R.<t> = GF(5)[]
        sage: f = (t+1)^2 * (t^2+t+1) / (t-1)^3
        sage: f.valuation(t+1)
        2
        sage: f.valuation(t-1)
        -3
        sage: f.valuation(t)
        0

    Python

        >>> from sage.all import *
        >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
        >>> f = (t+Integer(1))**Integer(2) * (t**Integer(2)+t+Integer(1)) / (t-Integer(1))**Integer(3)
        >>> f.valuation(t+Integer(1))
        2
        >>> f.valuation(t-Integer(1))
        -3
        >>> f.valuation(t)
        0

class sage.rings.fraction_field_FpT.FpT_Fp_section

  Bases: `Section`

  This class represents the section from GF(p)(t) back to GF(p)[t].

  EXAMPLES:

  Sage

      sage: R.<t> = GF(5)[]
      sage: K = R.fraction_field()
      sage: f = GF(5).convert_map_from(K); f
      Section map:
        From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Finite Field of size 5
      sage: type(f)
      <class 'sage.rings.fraction_field_FpT.FpT_Fp_section'>

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
      >>> K = R.fraction_field()
      >>> f = GF(Integer(5)).convert_map_from(K); f
      Section map:
        From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Finite Field of size 5
      >>> type(f)
      <class 'sage.rings.fraction_field_FpT.FpT_Fp_section'>

  Warning

  Comparison of `FpT_Fp_section` objects is not currently implemented. See Issue #23469.

  Sage

      sage: fprime = loads(dumps(f))
      sage: fprime == f
      False

      sage: fprime(3) == f(3)
      True

  Python

      >>> from sage.all import *
      >>> fprime = loads(dumps(f))
      >>> fprime == f
      False

      >>> fprime(Integer(3)) == f(Integer(3))
      True

class sage.rings.fraction_field_FpT.FpT_Polyring_section

  Bases: `Section`

  This class represents the section from GF(p)(t) back to GF(p)[t].

  EXAMPLES:

  Sage

      sage: R.<t> = GF(5)[]
      sage: K = R.fraction_field()
      sage: f = R.convert_map_from(K); f
      Section map:
        From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Univariate Polynomial Ring in t over Finite Field of size 5
      sage: type(f)
      <class 'sage.rings.fraction_field_FpT.FpT_Polyring_section'>

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
      >>> K = R.fraction_field()
      >>> f = R.convert_map_from(K); f
      Section map:
        From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Univariate Polynomial Ring in t over Finite Field of size 5
      >>> type(f)
      <class 'sage.rings.fraction_field_FpT.FpT_Polyring_section'>

  Warning

  Comparison of `FpT_Polyring_section` objects is not currently implemented. See Issue #23469.

  Sage

      sage: fprime = loads(dumps(f))
      sage: fprime == f
      False

      sage: fprime(1+t) == f(1+t)
      True

  Python

      >>> from sage.all import *
      >>> fprime = loads(dumps(f))
      >>> fprime == f
      False

      >>> fprime(Integer(1)+t) == f(Integer(1)+t)
      True

class sage.rings.fraction_field_FpT.FpT_iter

  Bases: `object`

  Return a class that iterates over all elements of an FpT.

  EXAMPLES:

  Sage

      sage: K = GF(3)['t'].fraction_field()
      sage: I = K.iter(1)
      sage: list(I)
      [0,
       1,
       2,
       t,
       t + 1,
       t + 2,
       2*t,
       2*t + 1,
       2*t + 2,
       1/t,
       2/t,
       (t + 1)/t,
       (t + 2)/t,
       (2*t + 1)/t,
       (2*t + 2)/t,
       1/(t + 1),
       2/(t + 1),
       t/(t + 1),
       (t + 2)/(t + 1),
       2*t/(t + 1),
       (2*t + 1)/(t + 1),
       1/(t + 2),
       2/(t + 2),
       t/(t + 2),
       (t + 1)/(t + 2),
       2*t/(t + 2),
       (2*t + 2)/(t + 2)]

  Python

      >>> from sage.all import *
      >>> K = GF(Integer(3))['t'].fraction_field()
      >>> I = K.iter(Integer(1))
      >>> list(I)
      [0,
       1,
       2,
       t,
       t + 1,
       t + 2,
       2*t,
       2*t + 1,
       2*t + 2,
       1/t,
       2/t,
       (t + 1)/t,
       (t + 2)/t,
       (2*t + 1)/t,
       (2*t + 2)/t,
       1/(t + 1),
       2/(t + 1),
       t/(t + 1),
       (t + 2)/(t + 1),
       2*t/(t + 1),
       (2*t + 1)/(t + 1),
       1/(t + 2),
       2/(t + 2),
       t/(t + 2),
       (t + 1)/(t + 2),
       2*t/(t + 2),
       (2*t + 2)/(t + 2)]

class sage.rings.fraction_field_FpT.Fp_FpT_coerce

  Bases: `RingHomomorphism`

  This class represents the coercion map from GF(p) to GF(p)(t).

  EXAMPLES:

  Sage

      sage: R.<t> = GF(5)[]
      sage: K = R.fraction_field()
      sage: f = K.coerce_map_from(GF(5)); f
      Ring morphism:
        From: Finite Field of size 5
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
      sage: type(f)
      <class 'sage.rings.fraction_field_FpT.Fp_FpT_coerce'>

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
      >>> K = R.fraction_field()
      >>> f = K.coerce_map_from(GF(Integer(5))); f
      Ring morphism:
        From: Finite Field of size 5
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
      >>> type(f)
      <class 'sage.rings.fraction_field_FpT.Fp_FpT_coerce'>

  section()

    Return the section of this inclusion: the partially defined map from `GF(p)(t)` back to `GF(p)`, defined on constant elements.

    EXAMPLES:

    Sage

        sage: R.<t> = GF(5)[]
        sage: K = R.fraction_field()
        sage: f = K.coerce_map_from(GF(5))
        sage: g = f.section(); g
        Section map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Finite Field of size 5
        sage: t = K.gen()
        sage: g(f(1,3,reduce=False))
        2
        sage: g(t)
        Traceback (most recent call last):
        ...
        ValueError: not constant
        sage: g(1/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

    Python

        >>> from sage.all import *
        >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
        >>> K = R.fraction_field()
        >>> f = K.coerce_map_from(GF(Integer(5)))
        >>> g = f.section(); g
        Section map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Finite Field of size 5
        >>> t = K.gen()
        >>> g(f(Integer(1),Integer(3),reduce=False))
        2
        >>> g(t)
        Traceback (most recent call last):
        ...
        ValueError: not constant
        >>> g(Integer(1)/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

class sage.rings.fraction_field_FpT.Polyring_FpT_coerce

  Bases: `RingHomomorphism`

  This class represents the coercion map from GF(p)[t] to GF(p)(t).

  EXAMPLES:

  Sage

      sage: R.<t> = GF(5)[]
      sage: K = R.fraction_field()
      sage: f = K.coerce_map_from(R); f
      Ring morphism:
        From: Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
      sage: type(f)
      <class 'sage.rings.fraction_field_FpT.Polyring_FpT_coerce'>

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
      >>> K = R.fraction_field()
      >>> f = K.coerce_map_from(R); f
      Ring morphism:
        From: Univariate Polynomial Ring in t over Finite Field of size 5
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
      >>> type(f)
      <class 'sage.rings.fraction_field_FpT.Polyring_FpT_coerce'>

  section()

    Return the section of this inclusion: the partially defined map from `GF(p)(t)` back to `GF(p)[t]`, defined on elements with unit denominator.

    EXAMPLES:

    Sage

        sage: R.<t> = GF(5)[]
        sage: K = R.fraction_field()
        sage: f = K.coerce_map_from(R)
        sage: g = f.section(); g
        Section map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Univariate Polynomial Ring in t over Finite Field of size 5
        sage: t = K.gen()
        sage: g(t)
        t
        sage: g(1/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

    Python

        >>> from sage.all import *
        >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
        >>> K = R.fraction_field()
        >>> f = K.coerce_map_from(R)
        >>> g = f.section(); g
        Section map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Univariate Polynomial Ring in t over Finite Field of size 5
        >>> t = K.gen()
        >>> g(t)
        t
        >>> g(Integer(1)/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

class sage.rings.fraction_field_FpT.ZZ_FpT_coerce

  Bases: `RingHomomorphism`

  This class represents the coercion map from ZZ to GF(p)(t).

  EXAMPLES:

  Sage

      sage: R.<t> = GF(17)[]
      sage: K = R.fraction_field()
      sage: f = K.coerce_map_from(ZZ); f
      Ring morphism:
        From: Integer Ring
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 17
      sage: type(f)
      <class 'sage.rings.fraction_field_FpT.ZZ_FpT_coerce'>

  Python

      >>> from sage.all import *
      >>> R = GF(Integer(17))['t']; (t,) = R._first_ngens(1)
      >>> K = R.fraction_field()
      >>> f = K.coerce_map_from(ZZ); f
      Ring morphism:
        From: Integer Ring
        To:   Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 17
      >>> type(f)
      <class 'sage.rings.fraction_field_FpT.ZZ_FpT_coerce'>

  section()

    Return the section of this inclusion: the partially defined map from `GF(p)(t)` back to `ZZ`, defined on constant elements.

    EXAMPLES:

    Sage

        sage: R.<t> = GF(5)[]
        sage: K = R.fraction_field()
        sage: f = K.coerce_map_from(ZZ)
        sage: g = f.section(); g
        Composite map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Integer Ring
          Defn:   Section map:
                  From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
                  To:   Finite Field of size 5
                then
                  Lifting map:
                  From: Finite Field of size 5
                  To:   Integer Ring
        sage: t = K.gen()
        sage: g(f(1,3,reduce=False))
        2
        sage: g(t)
        Traceback (most recent call last):
        ...
        ValueError: not constant
        sage: g(1/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

    Python

        >>> from sage.all import *
        >>> R = GF(Integer(5))['t']; (t,) = R._first_ngens(1)
        >>> K = R.fraction_field()
        >>> f = K.coerce_map_from(ZZ)
        >>> g = f.section(); g
        Composite map:
          From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
          To:   Integer Ring
          Defn:   Section map:
                  From: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5
                  To:   Finite Field of size 5
                then
                  Lifting map:
                  From: Finite Field of size 5
                  To:   Integer Ring
        >>> t = K.gen()
        >>> g(f(Integer(1),Integer(3),reduce=False))
        2
        >>> g(t)
        Traceback (most recent call last):
        ...
        ValueError: not constant
        >>> g(Integer(1)/t)
        Traceback (most recent call last):
        ...
        ValueError: not integral

sage.rings.fraction_field_FpT.unpickle_FpT_element(K, numer, denom)

  Used for pickling.