Fraction Field Elements¶
AUTHORS:
- William Stein (input from David Joyner, David Kohel, and Joe Wetherell)
- Sebastian Pancratz (2010-01-06): Rewrite of addition, multiplication and derivative to use Henrici’s algorithms [Ho72]
REFERENCES:
[Ho72] | E. Horowitz, “Algorithms for Rational Function Arithmetic Operations”, Annual ACM Symposium on Theory of Computing, Proceedings of the Fourth Annual ACM Symposium on Theory of Computing, pp. 108–118, 1972 |
-
class
sage.rings.fraction_field_element.
FractionFieldElement
¶ Bases:
sage.structure.element.FieldElement
EXAMPLES:
sage: K = FractionField(PolynomialRing(QQ, 'x')) sage: K Fraction Field of Univariate Polynomial Ring in x over Rational Field sage: loads(K.dumps()) == K True sage: x = K.gen() sage: f = (x^3 + x)/(17 - x^19); f (x^3 + x)/(-x^19 + 17) sage: loads(f.dumps()) == f True
TESTS:
Test if trac ticket #5451 is fixed:
sage: A = FiniteField(9,'theta')['t'] sage: K.<t> = FractionField(A) sage: f= 2/(t^2+2*t); g =t^9/(t^18 + t^10 + t^2);f+g (2*t^15 + 2*t^14 + 2*t^13 + 2*t^12 + 2*t^11 + 2*t^10 + 2*t^9 + t^7 + t^6 + t^5 + t^4 + t^3 + t^2 + t + 1)/(t^17 + t^9 + t)
Test if trac ticket #8671 is fixed:
sage: P.<n> = QQ[] sage: F = P.fraction_field() sage: P.one()//F.one() 1 sage: F.one().quo_rem(F.one()) (1, 0)
-
denominator
()¶ Return the denominator of
self
.EXAMPLES:
sage: R.<x,y> = ZZ[] sage: f = x/y+1; f (x + y)/y sage: f.denominator() y
-
is_one
()¶ Return
True
if this element is equal to one.EXAMPLES:
sage: F = ZZ['x,y'].fraction_field() sage: x,y = F.gens() sage: (x/x).is_one() True sage: (x/y).is_one() False
-
is_square
(root=False)¶ Returns whether or not
self
is a perfect square. If the optional argumentroot
isTrue
, then also returns a square root (orNone
, if the fraction field element is not square).INPUT:
root
– whether or not to also return a square root (default:False
)
OUTPUT:
bool
- whether or not a squareobject
- (optional) an actual square root if found, and None otherwise.
EXAMPLES:
sage: R.<t> = QQ[] sage: (1/t).is_square() False sage: (1/t^6).is_square() True sage: ((1+t)^4/t^6).is_square() True sage: (4*(1+t)^4/t^6).is_square() True sage: (2*(1+t)^4/t^6).is_square() False sage: ((1+t)/t^6).is_square() False sage: (4*(1+t)^4/t^6).is_square(root=True) (True, (2*t^2 + 4*t + 2)/t^3) sage: (2*(1+t)^4/t^6).is_square(root=True) (False, None) sage: R.<x> = QQ[] sage: a = 2*(x+1)^2 / (2*(x-1)^2); a (2*x^2 + 4*x + 2)/(2*x^2 - 4*x + 2) sage: a.numerator().is_square() False sage: a.is_square() True sage: (0/x).is_square() True
-
is_zero
()¶ Return
True
if this element is equal to zero.EXAMPLES:
sage: F = ZZ['x,y'].fraction_field() sage: x,y = F.gens() sage: t = F(0)/x sage: t.is_zero() True sage: u = 1/x - 1/x sage: u.is_zero() True sage: u.parent() is F True
-
numerator
()¶ Return the numerator of
self
.EXAMPLES:
sage: R.<x,y> = ZZ[] sage: f = x/y+1; f (x + y)/y sage: f.numerator() x + y
-
reduce
()¶ Divides out the gcd of the numerator and denominator.
Automatically called for exact rings, but because it may be numerically unstable for inexact rings it must be called manually in that case.
EXAMPLES:
sage: R.<x> = RealField(10)[] sage: f = (x^2+2*x+1)/(x+1); f (x^2 + 2.0*x + 1.0)/(x + 1.0) sage: f.reduce(); f x + 1.0
-
valuation
(v=None)¶ Return the valuation of
self
, assuming that the numerator and denominator have valuation functions defined on them.EXAMPLES:
sage: x = PolynomialRing(RationalField(),'x').gen() sage: f = (x^3 + x)/(x^2 - 2*x^3) sage: f (x^2 + 1)/(-2*x^2 + x) sage: f.valuation() -1 sage: f.valuation(x^2+1) 1
-
-
class
sage.rings.fraction_field_element.
FractionFieldElement_1poly_field
¶ Bases:
sage.rings.fraction_field_element.FractionFieldElement
A fraction field element where the parent is the fraction field of a univariate polynomial ring.
Many of the functions here are included for coherence with number fields.
-
is_integral
()¶ Returns whether this element is actually a polynomial.
EXAMPLES:
sage: R.<t> = QQ[] sage: elt = (t^2 + t - 2) / (t + 2); elt # == (t + 2)*(t - 1)/(t + 2) t - 1 sage: elt.is_integral() True sage: elt = (t^2 - t) / (t+2); elt # == t*(t - 1)/(t + 2) (t^2 - t)/(t + 2) sage: elt.is_integral() False
-
support
()¶ Returns a sorted list of primes dividing either the numerator or denominator of this element.
EXAMPLES:
sage: R.<t> = QQ[] sage: h = (t^14 + 2*t^12 - 4*t^11 - 8*t^9 + 6*t^8 + 12*t^6 - 4*t^5 - 8*t^3 + t^2 + 2)/(t^6 + 6*t^5 + 9*t^4 - 2*t^2 - 12*t - 18) sage: h.support() [t - 1, t + 3, t^2 + 2, t^2 + t + 1, t^4 - 2]
-
-
sage.rings.fraction_field_element.
is_FractionFieldElement
(x)¶ Returns whether or not
x
is a :class`FractionFieldElement`.EXAMPLES:
sage: from sage.rings.fraction_field_element import is_FractionFieldElement sage: R.<x> = ZZ[] sage: is_FractionFieldElement(x/2) False sage: is_FractionFieldElement(2/x) True sage: is_FractionFieldElement(1/3) False
-
sage.rings.fraction_field_element.
make_element
(parent, numerator, denominator)¶ Used for unpickling
FractionFieldElement
objects (and subclasses).EXAMPLES:
sage: from sage.rings.fraction_field_element import make_element sage: R = ZZ['x,y'] sage: x,y = R.gens() sage: F = R.fraction_field() sage: make_element(F, 1+x, 1+y) (x + 1)/(y + 1)
-
sage.rings.fraction_field_element.
make_element_old
(parent, cdict)¶ Used for unpickling old
FractionFieldElement
pickles.EXAMPLES:
sage: from sage.rings.fraction_field_element import make_element_old sage: R.<x,y> = ZZ[] sage: F = R.fraction_field() sage: make_element_old(F, {'_FractionFieldElement__numerator':x+y,'_FractionFieldElement__denominator':x-y}) (x + y)/(x - y)