23.7 Fraction Field Elements

Module: sage.rings.fraction_field_element

Fraction Field Elements

Author: William Stein (input from David Joyner, David Kohel, and Joe Wetherell)

Module-level Functions

is_FractionFieldElement( x)

Class: FractionFieldElement

class FractionFieldElement

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
FractionFieldElement( self, parent, numerator, [denominator=1], [coerce=True], [reduce=True])

Functions: copy,$ \,$ denominator,$ \,$ derivative,$ \,$ numerator,$ \,$ partial_fraction_decomposition,$ \,$ reduce,$ \,$ valuation

derivative( self)

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: self._derivative()

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)

partial_fraction_decomposition( self)

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.

Author: Robert Bradshaw (2007-05-31)

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
(1.0000*x^4 + 4.0000*x^2 + 1.0000*x + 3.0000)/(1.0000*x^5 - 1.0000*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/(1.0000*x - 1.0000), (-7.6294e-6*x^2 + 1.0000)/(1.0000*x^4 +
4.0000*x^2 + 4.0000)]
sage: sum(parts)
(1.0000*x^4 - 7.6294e-6*x^3 + 4.0000*x^2 + 1.0000*x + 3.0000)/(1.0000*x^5 -
1.0000*x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000)

valuation( self)

Return the valuation of self, assuming that the numerator and denominator have valuation functions defined on them.

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

Special Functions: __abs__,$ \,$ __call__,$ \,$ __cmp__,$ \,$ __float__,$ \,$ __init__,$ \,$ __int__,$ \,$ __invert__,$ \,$ __long__,$ \,$ __neg__,$ \,$ __pos__,$ \,$ __pow__,$ \,$ _add_,$ \,$ _derivative,$ \,$ _div_,$ \,$ _integer_,$ \,$ _is_atomic,$ \,$ _latex_,$ \,$ _magma_init_,$ \,$ _mul_,$ \,$ _rational_,$ \,$ _repr_,$ \,$ _sub_

__call__( self)

Evaluate the fraction at the given arguments. This assumes that a call function is defined for the numerator and denominator.

sage: x = MPolynomialRing(RationalField(),'x',3).gens()
sage: f = x[0] + x[1] - 2*x[1]*x[2]
sage: f
-2*x1*x2 + x0 + x1
sage: f(1,2,5)
-17
sage: h = f /(x[1] + x[2])
sage: h
(-2*x1*x2 + x0 + x1)/(x1 + x2)
sage: h(1,2,5)
-17/7

__pow__( self, right)

Returns self raised to the $ right^{th}$ power.

Note that we need to check whether or not right is negative so we don't set __numerator or __denominator to an element of the fraction field instead of the underlying ring.

sage: R = QQ['x','y']
sage: FR = R.fraction_field()
sage: x,y = FR.gens()
sage: a = x^2; a
x^2
sage: type(a.numerator())
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsi
ngular'>
sage: type(a.denominator())
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsi
ngular'>
sage: a = x^(-2); a
1/x^2
sage: type(a.numerator())         
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsi
ngular'>
sage: type(a.denominator())
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsi
ngular'>
sage: x^0
1
sage: ((x+y)/(x-y))^2
(x^2 + 2*x*y + y^2)/(x^2 - 2*x*y + y^2)
sage: ((x+y)/(x-y))^-2
(x^2 - 2*x*y + y^2)/(x^2 + 2*x*y + y^2)
sage: ((x+y)/(x-y))^0
1

_derivative( self, [var=None])

Return the derivative of this rational function with respect to the variable var.

SEE ALSO: self.derivative()

sage: F = FractionField(PolynomialRing(RationalField(),'x'))
sage: x = F.gen()
sage: t = 1/x^2
sage: t._derivative(x)
-2/x^3
sage: t.derivative()
-2/x^3

sage: F = FractionField(PolynomialRing(RationalField(),'x,y'))
sage: x,y = F.gens()
sage: t = (x*y/(x+y))
sage: t._derivative(x)
y^2/(x^2 + 2*x*y + y^2)
sage: t._derivative(y)
x^2/(x^2 + 2*x*y + y^2)

_latex_( self)

Return a latex representation of this rational function.

sage: R = PolynomialRing(QQ, 'x').fraction_field()
sage: x = R.gen()
sage: a = x^2 / 1
sage: latex(a)
x^{2}
sage: latex(x^2/(x^2+1))
\frac{x^{2}}{x^{2} + 1}
sage: a = 1/x
sage: a._FractionFieldElement__numerator = R(0)
sage: latex(a)
0

_magma_init_( self)

Return a string representation of self Magma can understand.

sage: R.<x> = ZZ[]
sage: magma((x^2 + x + 1)/(x + 1))          # optional
(x^2 + x + 1)/(x + 1)

sage: R.<x,y> = QQ[]
sage: magma((x+y)/x)                        # optional
(x + y)/x

See About this document... for information on suggesting changes.