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, x = FractionField(PolynomialRing(QQ, 'x')).objgen()
sage: K
Fraction Field of Univariate Polynomial Ring in x over Rational Field
sage: loads(K.dumps()) == K
True
sage: f = (x^3 + x)/(17 - x^19); f
(x^3 + x)/(-x^19 + 17)
sage: loads(f.dumps()) == f
True

TESTS:

Test if #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 #8671 is fixed:

sage: P.<n> = QQ[]
sage: F = P.fraction_field()
sage: P.one_element()//F.one_element()
1
sage: F.one_element().quo_rem(F.one_element())
(1, 0)
denominator()

EXAMPLES:

sage: R.<x,y> = ZZ[]
sage: f = x/y+1; f
(x + y)/y
sage: f.denominator()
y
derivative(*args)

The derivative of this rational function, with respect to variables supplied in args.

Multiple variables and iteration counts may be supplied; see documentation for the global derivative() function for more details.

See also

_derivative()

EXAMPLES:

sage: F = FractionField(PolynomialRing(RationalField(),'x'))
sage: x = F.gen()
sage: (1/x).derivative()
-1/x^2
sage: (x+1/x).derivative(x, 2)
2/x^3
sage: F = FractionField(PolynomialRing(RationalField(),'x,y'))
sage: x,y = F.gens()
sage: (1/(x+y)).derivative(x,y)
2/(x^3 + 3*x^2*y + 3*x*y^2 + y^3)
factor(*args, **kwds)

Return the factorization of self over the base ring.

INPUT:

  • *args - Arbitrary arguments suitable over the base ring
  • **kwds - Arbitrary keyword arguments suitable over the base ring

OUTPUT:

  • Factorization of self over the base ring

EXAMPLES:

sage: K.<x> = QQ[]
sage: f = (x^3+x)/(x-3)
sage: f.factor()
(x - 3)^-1 * x * (x^2 + 1)

Here is an example to show that ticket #7868 has been resolved:

sage: R.<x,y> = GF(2)[]
sage: f = x*y/(x+y)
sage: f.factor()
...
NotImplementedError: proof = True factorization not implemented.  Call factor with proof=False.
sage: f.factor(proof=False)
(x + y)^-1 * y * x
is_one()

Returns 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_zero()

Returns 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()

EXAMPLES:

sage: R.<x,y> = ZZ[]
sage: f = x/y+1; f
(x + y)/y
sage: f.numerator()
x + y
partial_fraction_decomposition()

Decomposes fraction field element into a whole part and a list of fraction field elements over prime power denominators.

The sum will be equal to the original fraction.

AUTHORS:

  • Robert Bradshaw (2007-05-31)

EXAMPLES:

sage: S.<t> = QQ[]
sage: q = 1/(t+1) + 2/(t+2) + 3/(t-3); q
(6*t^2 + 4*t - 6)/(t^3 - 7*t - 6)
sage: whole, parts = q.partial_fraction_decomposition(); parts
[3/(t - 3), 1/(t + 1), 2/(t + 2)]
sage: sum(parts) == q
True
sage: q = 1/(t^3+1) + 2/(t^2+2) + 3/(t-3)^5
sage: whole, parts = q.partial_fraction_decomposition(); parts
[1/3/(t + 1), 3/(t^5 - 15*t^4 + 90*t^3 - 270*t^2 + 405*t - 243), (-1/3*t + 2/3)/(t^2 - t + 1), 2/(t^2 + 2)]
sage: sum(parts) == q
True

We do the best we can over in-exact fields:

sage: R.<x> = RealField(20)[]
sage: q = 1/(x^2 + 2)^2 + 1/(x-1); q
(x^4 + 4.0000*x^2 + x + 3.0000)/(x^5 - x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000)
sage: whole, parts = q.partial_fraction_decomposition(); parts
[1.0000/(x - 1.0000), 1.0000/(x^4 + 4.0000*x^2 + 4.0000)]
sage: sum(parts)
(x^4 + 4.0000*x^2 + x + 3.0000)/(x^5 - x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000)

TESTS:

We test partial fraction for irreducible denominators:

sage: R.<x> = ZZ[]
sage: q = x^2/(x-1)
sage: q.partial_fraction_decomposition()
(x + 1, [1/(x - 1)])
sage: q = x^10/(x-1)^5
sage: whole, parts = q.partial_fraction_decomposition()
sage: whole + sum(parts) == q
True

And also over finite fields (see trac #6052):

sage: R.<x> = GF(2)[]
sage: q = (x+1)/(x^3+x+1)
sage: q.partial_fraction_decomposition()
(0, [(x + 1)/(x^3 + x + 1)])
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()

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.rings.fraction_field_element.is_FractionFieldElement(x)

Returns whether or not x is of type 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)

Previous topic

Fraction Field of Integral Domains

Next topic

Quotient Rings

This Page