Univariate rational functions over prime fields¶
- class sage.rings.fraction_field_FpT.FpT(R, names=None)[source]¶
Bases:
FractionField_1poly_field
This class represents the fraction field \(\GF{p}(T)\) for \(2 < p < \sqrt{2^31-1}\).
EXAMPLES:
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
>>> 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
R.<T> = GF(71)[] K = FractionField(R); K 1-1/T parent(1-1/T) is K
- INTEGER_LIMIT = 46341¶
- iter(bound=None, start=None)[source]¶
EXAMPLES:
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)]
>>> 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)]
from sage.rings.fraction_field_FpT import * R.<t> = FpT(GF(5)['t']) list(R.iter(2))[350:355]
- class sage.rings.fraction_field_FpT.FpTElement[source]¶
Bases:
FieldElement
An element of an
FpT
fraction field.- denom()[source]¶
Return the denominator of this element, as an element of the polynomial ring.
EXAMPLES:
sage: K = GF(11)['t'].fraction_field() sage: t = K.gen(0); a = (t + 1/t)^3 - 1 sage: a.denom() t^3
>>> 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
K = GF(11)['t'].fraction_field() t = K.gen(0); a = (t + 1/t)^3 - 1 a.denom()
- denominator()[source]¶
Return the denominator of this element, as an element of the polynomial ring.
EXAMPLES:
sage: K = GF(11)['t'].fraction_field() sage: t = K.gen(0); a = (t + 1/t)^3 - 1 sage: a.denominator() t^3
>>> 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
K = GF(11)['t'].fraction_field() t = K.gen(0); a = (t + 1/t)^3 - 1 a.denominator()
- factor()[source]¶
EXAMPLES:
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
>>> 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
K = Frac(GF(5)['t']) t = K.gen() f = 2 * (t+1) * (t^2+t+1)^2 / (t-1) factor(f)
- is_square()[source]¶
Return
True
if this element is the square of another element of the fraction field.EXAMPLES:
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
>>> 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
K = GF(13)['t'].fraction_field(); t = K.gen() t.is_square() (1/t^2).is_square() K(0).is_square()
- next()[source]¶
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: 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
>>> 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
from sage.rings.fraction_field_FpT import * R.<t> = FpT(GF(3)['t']) a = R(0) for _ in range(30): a = a.next() print(a)
- numer()[source]¶
Return the numerator of this element, as an element of the polynomial ring.
EXAMPLES:
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
>>> 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
K = GF(11)['t'].fraction_field() t = K.gen(0); a = (t + 1/t)^3 - 1 a.numer()
- numerator()[source]¶
Return the numerator of this element, as an element of the polynomial ring.
EXAMPLES:
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
>>> 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
K = GF(11)['t'].fraction_field() t = K.gen(0); a = (t + 1/t)^3 - 1 a.numerator()
- sqrt(extend=True, all=False)[source]¶
Return the square root of this element.
INPUT:
extend
– boolean (default:True
); ifTrue
, return a square root in an extension ring, if necessary. Otherwise, raise aValueError
if the square is not in the base ring.all
– boolean (default:False
); ifTrue
, return all square roots of self, instead of just one
EXAMPLES:
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
>>> 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
from sage.rings.fraction_field_FpT import * K = GF(7)['t'].fraction_field(); t = K.gen(0) p = (t + 2)^2/(3*t^3 + 1)^4 p.sqrt() p.sqrt()^2 == p
- subs(in_dict=None, *args, **kwds)[source]¶
EXAMPLES:
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)
>>> 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)
K = Frac(GF(11)['t']) t = K.gen() f = (t+1)/(t-1) f.subs(t=2) f.subs(X=2)
- valuation(v)[source]¶
Return the valuation of
self
at \(v\).EXAMPLES:
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
>>> 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
R.<t> = GF(5)[] f = (t+1)^2 * (t^2+t+1) / (t-1)^3 f.valuation(t+1) f.valuation(t-1) f.valuation(t)
- class sage.rings.fraction_field_FpT.FpT_Fp_section[source]¶
Bases:
Section
This class represents the section from GF(p)(t) back to GF(p)[t].
EXAMPLES:
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'>
>>> 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'>
R.<t> = GF(5)[] K = R.fraction_field() f = GF(5).convert_map_from(K); f type(f)
Warning
Comparison of
FpT_Fp_section
objects is not currently implemented. See Issue #23469.sage: fprime = loads(dumps(f)) sage: fprime == f False sage: fprime(3) == f(3) True
>>> from sage.all import * >>> fprime = loads(dumps(f)) >>> fprime == f False >>> fprime(Integer(3)) == f(Integer(3)) True
fprime = loads(dumps(f)) fprime == f fprime(3) == f(3)
- class sage.rings.fraction_field_FpT.FpT_Polyring_section[source]¶
Bases:
Section
This class represents the section from GF(p)(t) back to GF(p)[t].
EXAMPLES:
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'>
>>> 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'>
R.<t> = GF(5)[] K = R.fraction_field() f = R.convert_map_from(K); f type(f)
Warning
Comparison of
FpT_Polyring_section
objects is not currently implemented. See Issue #23469.sage: fprime = loads(dumps(f)) sage: fprime == f False sage: fprime(1+t) == f(1+t) True
>>> from sage.all import * >>> fprime = loads(dumps(f)) >>> fprime == f False >>> fprime(Integer(1)+t) == f(Integer(1)+t) True
fprime = loads(dumps(f)) fprime == f fprime(1+t) == f(1+t)
- class sage.rings.fraction_field_FpT.FpT_iter[source]¶
Bases:
object
Return a class that iterates over all elements of an FpT.
EXAMPLES:
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)]
>>> 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)]
K = GF(3)['t'].fraction_field() I = K.iter(1) list(I)
- class sage.rings.fraction_field_FpT.Fp_FpT_coerce[source]¶
Bases:
RingHomomorphism
This class represents the coercion map from GF(p) to GF(p)(t).
EXAMPLES:
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'>
>>> 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'>
R.<t> = GF(5)[] K = R.fraction_field() f = K.coerce_map_from(GF(5)); f type(f)
- section()[source]¶
Return the section of this inclusion: the partially defined map from
GF(p)(t)
back toGF(p)
, defined on constant elements.EXAMPLES:
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
>>> 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
R.<t> = GF(5)[] K = R.fraction_field() f = K.coerce_map_from(GF(5)) g = f.section(); g t = K.gen() g(f(1,3,reduce=False)) g(t) g(1/t)
- class sage.rings.fraction_field_FpT.Polyring_FpT_coerce[source]¶
Bases:
RingHomomorphism
This class represents the coercion map from GF(p)[t] to GF(p)(t).
EXAMPLES:
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'>
>>> 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'>
R.<t> = GF(5)[] K = R.fraction_field() f = K.coerce_map_from(R); f type(f)
- section()[source]¶
Return the section of this inclusion: the partially defined map from
GF(p)(t)
back toGF(p)[t]
, defined on elements with unit denominator.EXAMPLES:
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
>>> 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
R.<t> = GF(5)[] K = R.fraction_field() f = K.coerce_map_from(R) g = f.section(); g t = K.gen() g(t) g(1/t)
- class sage.rings.fraction_field_FpT.ZZ_FpT_coerce[source]¶
Bases:
RingHomomorphism
This class represents the coercion map from ZZ to GF(p)(t).
EXAMPLES:
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'>
>>> 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'>
R.<t> = GF(17)[] K = R.fraction_field() f = K.coerce_map_from(ZZ); f type(f)
- section()[source]¶
Return the section of this inclusion: the partially defined map from
GF(p)(t)
back toZZ
, defined on constant elements.EXAMPLES:
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
>>> 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
R.<t> = GF(5)[] K = R.fraction_field() f = K.coerce_map_from(ZZ) g = f.section(); g t = K.gen() g(f(1,3,reduce=False)) g(t) g(1/t)