Quotient fields¶
- class sage.categories.quotient_fields.QuotientFields[source]¶
- Bases: - Category_singleton- The category of quotient fields over an integral domain. - EXAMPLES: - sage: QuotientFields() Category of quotient fields sage: QuotientFields().super_categories() [Category of fields] - >>> from sage.all import * >>> QuotientFields() Category of quotient fields >>> QuotientFields().super_categories() [Category of fields] - class ElementMethods[source]¶
- Bases: - object- denominator()[source]¶
- Constructor for abstract methods. - EXAMPLES: - sage: def f(x): ....: "doc of f" ....: return 1 sage: x = abstract_method(f); x <abstract method f at ...> sage: x.__doc__ 'doc of f' sage: x.__name__ 'f' sage: x.__module__ '__main__' - >>> from sage.all import * >>> def f(x): ... "doc of f" ... return Integer(1) >>> x = abstract_method(f); x <abstract method f at ...> >>> x.__doc__ 'doc of f' >>> x.__name__ 'f' >>> x.__module__ '__main__' 
 - derivative(*args)[source]¶
- 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.<x> = Frac(QQ['x']) sage: (1/x).derivative() -1/x^2 - >>> from sage.all import * >>> F = Frac(QQ['x'], names=('x',)); (x,) = F._first_ngens(1) >>> (Integer(1)/x).derivative() -1/x^2 - sage: (x+1/x).derivative(x, 2) 2/x^3 - >>> from sage.all import * >>> (x+Integer(1)/x).derivative(x, Integer(2)) 2/x^3 - sage: F.<x,y> = Frac(QQ['x,y']) sage: (1/(x+y)).derivative(x,y) 2/(x^3 + 3*x^2*y + 3*x*y^2 + y^3) - >>> from sage.all import * >>> F = Frac(QQ['x,y'], names=('x', 'y',)); (x, y,) = F._first_ngens(2) >>> (Integer(1)/(x+y)).derivative(x,y) 2/(x^3 + 3*x^2*y + 3*x*y^2 + y^3) 
 - factor(*args, **kwds)[source]¶
- Return the factorization of - selfover the base ring.- INPUT: - *args– arbitrary arguments suitable over the base ring
- **kwds– arbitrary keyword arguments suitable over the base ring
 - OUTPUT: factorization of - selfover the base ring- EXAMPLES: - sage: K.<x> = QQ[] sage: f = (x^3+x)/(x-3) sage: f.factor() # needs sage.libs.pari (x - 3)^-1 * x * (x^2 + 1) - >>> from sage.all import * >>> K = QQ['x']; (x,) = K._first_ngens(1) >>> f = (x**Integer(3)+x)/(x-Integer(3)) >>> f.factor() # needs sage.libs.pari (x - 3)^-1 * x * (x^2 + 1) - Here is an example to show that Issue #7868 has been resolved: - sage: R.<x,y> = GF(2)[] sage: f = x*y/(x+y) sage: f.factor() # needs sage.rings.finite_rings (x + y)^-1 * y * x - >>> from sage.all import * >>> R = GF(Integer(2))['x, y']; (x, y,) = R._first_ngens(2) >>> f = x*y/(x+y) >>> f.factor() # needs sage.rings.finite_rings (x + y)^-1 * y * x 
 - gcd(other)[source]¶
- Greatest common divisor. - Note - In a field, the greatest common divisor is not very informative, as it is only determined up to a unit. But in the fraction field of an integral domain that provides both gcd and lcm, it is possible to be a bit more specific and define the gcd uniquely up to a unit of the base ring (rather than in the fraction field). - AUTHOR: - Simon King (2011-02): See Issue #10771 
 - EXAMPLES: - sage: # needs sage.libs.pari sage: R.<x> = QQ['x'] sage: p = (1+x)^3*(1+2*x^2)/(1-x^5) sage: q = (1+x)^2*(1+3*x^2)/(1-x^4) sage: factor(p) (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 sage: factor(q) (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) sage: gcd(p, q) (x + 1)/(x^7 + x^5 - x^2 - 1) sage: factor(gcd(p, q)) (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^4 + x^3 + x^2 + x + 1)^-1 sage: factor(gcd(p, 1 + x)) (x - 1)^-1 * (x + 1) * (x^4 + x^3 + x^2 + x + 1)^-1 sage: factor(gcd(1 + x, q)) (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 - >>> from sage.all import * >>> # needs sage.libs.pari >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> p = (Integer(1)+x)**Integer(3)*(Integer(1)+Integer(2)*x**Integer(2))/(Integer(1)-x**Integer(5)) >>> q = (Integer(1)+x)**Integer(2)*(Integer(1)+Integer(3)*x**Integer(2))/(Integer(1)-x**Integer(4)) >>> factor(p) (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 >>> factor(q) (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) >>> gcd(p, q) (x + 1)/(x^7 + x^5 - x^2 - 1) >>> factor(gcd(p, q)) (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^4 + x^3 + x^2 + x + 1)^-1 >>> factor(gcd(p, Integer(1) + x)) (x - 1)^-1 * (x + 1) * (x^4 + x^3 + x^2 + x + 1)^-1 >>> factor(gcd(Integer(1) + x, q)) (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 
 - lcm(other)[source]¶
- Least common multiple. - In a field, the least common multiple is not very informative, as it is only determined up to a unit. But in the fraction field of an integral domain that provides both gcd and lcm, it is reasonable to be a bit more specific and to define the least common multiple so that it restricts to the usual least common multiple in the base ring and is unique up to a unit of the base ring (rather than up to a unit of the fraction field). - The least common multiple is easily described in terms of the prime decomposition. A rational number can be written as a product of primes with integer (positive or negative) powers in a unique way. The least common multiple of two rational numbers \(x\) and \(y\) can then be defined by specifying that the exponent of every prime \(p\) in \(lcm(x,y)\) is the supremum of the exponents of \(p\) in \(x\), and the exponent of \(p\) in \(y\) (where the primes that does not appear in the decomposition of \(x\) or \(y\) are considered to have exponent zero). - AUTHOR: - Simon King (2011-02): See Issue #10771 
 - EXAMPLES: - sage: lcm(2/3, 1/5) 2 - >>> from sage.all import * >>> lcm(Integer(2)/Integer(3), Integer(1)/Integer(5)) 2 - Indeed \(2/3 = 2^1 3^{-1} 5^0\) and \(1/5 = 2^0 3^0 5^{-1}\), so \(lcm(2/3,1/5)= 2^1 3^0 5^0 = 2\). - sage: lcm(1/3, 1/5) 1 sage: lcm(1/3, 1/6) 1/3 - Some more involved examples: - sage: # needs sage.libs.pari sage: R.<x> = QQ[] sage: p = (1+x)^3*(1+2*x^2)/(1-x^5) sage: q = (1+x)^2*(1+3*x^2)/(1-x^4) sage: factor(p) (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 sage: factor(q) (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) sage: factor(lcm(p, q)) (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/3) * (x^2 + 1/2) sage: factor(lcm(p, 1 + x)) (x + 1)^3 * (x^2 + 1/2) sage: factor(lcm(1 + x, q)) (x + 1) * (x^2 + 1/3) - >>> from sage.all import * >>> # needs sage.libs.pari >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> p = (Integer(1)+x)**Integer(3)*(Integer(1)+Integer(2)*x**Integer(2))/(Integer(1)-x**Integer(5)) >>> q = (Integer(1)+x)**Integer(2)*(Integer(1)+Integer(3)*x**Integer(2))/(Integer(1)-x**Integer(4)) >>> factor(p) (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 >>> factor(q) (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) >>> factor(lcm(p, q)) (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/3) * (x^2 + 1/2) >>> factor(lcm(p, Integer(1) + x)) (x + 1)^3 * (x^2 + 1/2) >>> factor(lcm(Integer(1) + x, q)) (x + 1) * (x^2 + 1/3) 
 - numerator()[source]¶
- Constructor for abstract methods. - EXAMPLES: - sage: def f(x): ....: "doc of f" ....: return 1 sage: x = abstract_method(f); x <abstract method f at ...> sage: x.__doc__ 'doc of f' sage: x.__name__ 'f' sage: x.__module__ '__main__' - >>> from sage.all import * >>> def f(x): ... "doc of f" ... return Integer(1) >>> x = abstract_method(f); x <abstract method f at ...> >>> x.__doc__ 'doc of f' >>> x.__name__ 'f' >>> x.__module__ '__main__' 
 - partial_fraction_decomposition(decompose_powers=True)[source]¶
- Decompose 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. - INPUT: - decompose_powers– boolean (default:- True); whether to decompose prime power denominators as opposed to having a single term for each irreducible factor of the denominator
 - OUTPUT: partial fraction decomposition of - selfover the base ring- AUTHORS: - Robert Bradshaw (2007-05-31) 
 - EXAMPLES: - sage: # needs sage.libs.pari 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 sage: q = 2*t / (t + 3)^2 sage: q.partial_fraction_decomposition() (0, [2/(t + 3), -6/(t^2 + 6*t + 9)]) sage: for p in q.partial_fraction_decomposition()[1]: ....: print(p.factor()) (2) * (t + 3)^-1 (-6) * (t + 3)^-2 sage: q.partial_fraction_decomposition(decompose_powers=False) (0, [2*t/(t^2 + 6*t + 9)]) - >>> from sage.all import * >>> # needs sage.libs.pari >>> S = QQ['t']; (t,) = S._first_ngens(1) >>> q = Integer(1)/(t+Integer(1)) + Integer(2)/(t+Integer(2)) + Integer(3)/(t-Integer(3)); q (6*t^2 + 4*t - 6)/(t^3 - 7*t - 6) >>> whole, parts = q.partial_fraction_decomposition(); parts [3/(t - 3), 1/(t + 1), 2/(t + 2)] >>> sum(parts) == q True >>> q = Integer(1)/(t**Integer(3)+Integer(1)) + Integer(2)/(t**Integer(2)+Integer(2)) + Integer(3)/(t-Integer(3))**Integer(5) >>> 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)] >>> sum(parts) == q True >>> q = Integer(2)*t / (t + Integer(3))**Integer(2) >>> q.partial_fraction_decomposition() (0, [2/(t + 3), -6/(t^2 + 6*t + 9)]) >>> for p in q.partial_fraction_decomposition()[Integer(1)]: ... print(p.factor()) (2) * (t + 3)^-1 (-6) * (t + 3)^-2 >>> q.partial_fraction_decomposition(decompose_powers=False) (0, [2*t/(t^2 + 6*t + 9)]) - We can decompose over a given algebraic extension: - sage: R.<x> = QQ[sqrt(2)][] # needs sage.rings.number_field sage.symbolic sage: r = 1/(x^4+1) # needs sage.rings.number_field sage.symbolic sage: r.partial_fraction_decomposition() # needs sage.rings.number_field sage.symbolic (0, [(-1/4*sqrt2*x + 1/2)/(x^2 - sqrt2*x + 1), (1/4*sqrt2*x + 1/2)/(x^2 + sqrt2*x + 1)]) sage: R.<x> = QQ[I][] # of QQ[sqrt(-1)] # needs sage.rings.number_field sage.symbolic sage: r = 1/(x^4+1) # needs sage.rings.number_field sage.symbolic sage: r.partial_fraction_decomposition() # needs sage.rings.number_field sage.symbolic (0, [(-1/2*I)/(x^2 - I), 1/2*I/(x^2 + I)]) - >>> from sage.all import * >>> R = QQ[sqrt(Integer(2))]['x']; (x,) = R._first_ngens(1)# needs sage.rings.number_field sage.symbolic >>> r = Integer(1)/(x**Integer(4)+Integer(1)) # needs sage.rings.number_field sage.symbolic >>> r.partial_fraction_decomposition() # needs sage.rings.number_field sage.symbolic (0, [(-1/4*sqrt2*x + 1/2)/(x^2 - sqrt2*x + 1), (1/4*sqrt2*x + 1/2)/(x^2 + sqrt2*x + 1)]) >>> R = QQ[I]['x']; (x,) = R._first_ngens(1)# of QQ[sqrt(-1)] # needs sage.rings.number_field sage.symbolic >>> r = Integer(1)/(x**Integer(4)+Integer(1)) # needs sage.rings.number_field sage.symbolic >>> r.partial_fraction_decomposition() # needs sage.rings.number_field sage.symbolic (0, [(-1/2*I)/(x^2 - I), 1/2*I/(x^2 + I)]) - We can also ask Sage to find the least extension where the denominator factors in linear terms: - sage: # needs sage.rings.number_field sage: R.<x> = QQ[] sage: r = 1/(x^4+2) sage: N = r.denominator().splitting_field('a'); N Number Field in a with defining polynomial x^8 - 8*x^6 + 28*x^4 + 16*x^2 + 36 sage: R1.<x1> = N[] sage: r1 = 1/(x1^4+2) sage: r1.partial_fraction_decomposition() (0, [(-1/224*a^6 + 13/448*a^4 - 5/56*a^2 - 25/224)/(x1 - 1/28*a^6 + 13/56*a^4 - 5/7*a^2 - 25/28), (1/224*a^6 - 13/448*a^4 + 5/56*a^2 + 25/224)/(x1 + 1/28*a^6 - 13/56*a^4 + 5/7*a^2 + 25/28), (-5/1344*a^7 + 43/1344*a^5 - 85/672*a^3 - 31/672*a)/(x1 - 5/168*a^7 + 43/168*a^5 - 85/84*a^3 - 31/84*a), (5/1344*a^7 - 43/1344*a^5 + 85/672*a^3 + 31/672*a)/(x1 + 5/168*a^7 - 43/168*a^5 + 85/84*a^3 + 31/84*a)]) - >>> from sage.all import * >>> # needs sage.rings.number_field >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> r = Integer(1)/(x**Integer(4)+Integer(2)) >>> N = r.denominator().splitting_field('a'); N Number Field in a with defining polynomial x^8 - 8*x^6 + 28*x^4 + 16*x^2 + 36 >>> R1 = N['x1']; (x1,) = R1._first_ngens(1) >>> r1 = Integer(1)/(x1**Integer(4)+Integer(2)) >>> r1.partial_fraction_decomposition() (0, [(-1/224*a^6 + 13/448*a^4 - 5/56*a^2 - 25/224)/(x1 - 1/28*a^6 + 13/56*a^4 - 5/7*a^2 - 25/28), (1/224*a^6 - 13/448*a^4 + 5/56*a^2 + 25/224)/(x1 + 1/28*a^6 - 13/56*a^4 + 5/7*a^2 + 25/28), (-5/1344*a^7 + 43/1344*a^5 - 85/672*a^3 - 31/672*a)/(x1 - 5/168*a^7 + 43/168*a^5 - 85/84*a^3 - 31/84*a), (5/1344*a^7 - 43/1344*a^5 + 85/672*a^3 + 31/672*a)/(x1 + 5/168*a^7 - 43/168*a^5 + 85/84*a^3 + 31/84*a)]) - Or we may work directly over an algebraically closed field: - sage: R.<x> = QQbar[] # needs sage.rings.number_field sage: r = 1/(x^4+1) # needs sage.rings.number_field sage: r.partial_fraction_decomposition() # needs sage.rings.number_field (0, [(-0.1767766952966369? - 0.1767766952966369?*I)/(x - 0.7071067811865475? - 0.7071067811865475?*I), (-0.1767766952966369? + 0.1767766952966369?*I)/(x - 0.7071067811865475? + 0.7071067811865475?*I), (0.1767766952966369? - 0.1767766952966369?*I)/(x + 0.7071067811865475? - 0.7071067811865475?*I), (0.1767766952966369? + 0.1767766952966369?*I)/(x + 0.7071067811865475? + 0.7071067811865475?*I)]) - >>> from sage.all import * >>> R = QQbar['x']; (x,) = R._first_ngens(1)# needs sage.rings.number_field >>> r = Integer(1)/(x**Integer(4)+Integer(1)) # needs sage.rings.number_field >>> r.partial_fraction_decomposition() # needs sage.rings.number_field (0, [(-0.1767766952966369? - 0.1767766952966369?*I)/(x - 0.7071067811865475? - 0.7071067811865475?*I), (-0.1767766952966369? + 0.1767766952966369?*I)/(x - 0.7071067811865475? + 0.7071067811865475?*I), (0.1767766952966369? - 0.1767766952966369?*I)/(x + 0.7071067811865475? - 0.7071067811865475?*I), (0.1767766952966369? + 0.1767766952966369?*I)/(x + 0.7071067811865475? + 0.7071067811865475?*I)]) - We do the best we can over inexact fields: - sage: # needs sage.rings.number_field sage.rings.real_mpfr sage: R.<x> = RealField(20)[] sage: q = 1/(x^2 + x + 2)^2 + 1/(x-1); q (x^4 + 2.0000*x^3 + 5.0000*x^2 + 5.0000*x + 3.0000)/(x^5 + x^4 + 3.0000*x^3 - x^2 - 4.0000) sage: whole, parts = q.partial_fraction_decomposition(); parts [1.0000/(x - 1.0000), 1.0000/(x^4 + 2.0000*x^3 + 5.0000*x^2 + 4.0000*x + 4.0000)] sage: sum(parts) (x^4 + 2.0000*x^3 + 5.0000*x^2 + 5.0000*x + 3.0000)/(x^5 + x^4 + 3.0000*x^3 - x^2 - 4.0000) - >>> from sage.all import * >>> # needs sage.rings.number_field sage.rings.real_mpfr >>> R = RealField(Integer(20))['x']; (x,) = R._first_ngens(1) >>> q = Integer(1)/(x**Integer(2) + x + Integer(2))**Integer(2) + Integer(1)/(x-Integer(1)); q (x^4 + 2.0000*x^3 + 5.0000*x^2 + 5.0000*x + 3.0000)/(x^5 + x^4 + 3.0000*x^3 - x^2 - 4.0000) >>> whole, parts = q.partial_fraction_decomposition(); parts [1.0000/(x - 1.0000), 1.0000/(x^4 + 2.0000*x^3 + 5.0000*x^2 + 4.0000*x + 4.0000)] >>> sum(parts) (x^4 + 2.0000*x^3 + 5.0000*x^2 + 5.0000*x + 3.0000)/(x^5 + x^4 + 3.0000*x^3 - x^2 - 4.0000) 
 - xgcd(other)[source]¶
- Return a triple - (g,s,t)of elements of that field such that- gis the greatest common divisor of- selfand- otherand- g = s*self + t*other.- Note - In a field, the greatest common divisor is not very informative, as it is only determined up to a unit. But in the fraction field of an integral domain that provides both xgcd and lcm, it is possible to be a bit more specific and define the gcd uniquely up to a unit of the base ring (rather than in the fraction field). - EXAMPLES: - sage: QQ(3).xgcd(QQ(2)) (1, 1, -1) sage: QQ(3).xgcd(QQ(1/2)) (1/2, 0, 1) sage: QQ(1/3).xgcd(QQ(2)) (1/3, 1, 0) sage: QQ(3/2).xgcd(QQ(5/2)) (1/2, 2, -1) sage: R.<x> = QQ['x'] sage: p = (1+x)^3*(1+2*x^2)/(1-x^5) sage: q = (1+x)^2*(1+3*x^2)/(1-x^4) sage: factor(p) # needs sage.libs.pari (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 sage: factor(q) # needs sage.libs.pari (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) sage: g, s, t = xgcd(p, q) sage: g (x + 1)/(x^7 + x^5 - x^2 - 1) sage: g == s*p + t*q True - >>> from sage.all import * >>> QQ(Integer(3)).xgcd(QQ(Integer(2))) (1, 1, -1) >>> QQ(Integer(3)).xgcd(QQ(Integer(1)/Integer(2))) (1/2, 0, 1) >>> QQ(Integer(1)/Integer(3)).xgcd(QQ(Integer(2))) (1/3, 1, 0) >>> QQ(Integer(3)/Integer(2)).xgcd(QQ(Integer(5)/Integer(2))) (1/2, 2, -1) >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> p = (Integer(1)+x)**Integer(3)*(Integer(1)+Integer(2)*x**Integer(2))/(Integer(1)-x**Integer(5)) >>> q = (Integer(1)+x)**Integer(2)*(Integer(1)+Integer(3)*x**Integer(2))/(Integer(1)-x**Integer(4)) >>> factor(p) # needs sage.libs.pari (-2) * (x - 1)^-1 * (x + 1)^3 * (x^2 + 1/2) * (x^4 + x^3 + x^2 + x + 1)^-1 >>> factor(q) # needs sage.libs.pari (-3) * (x - 1)^-1 * (x + 1) * (x^2 + 1)^-1 * (x^2 + 1/3) >>> g, s, t = xgcd(p, q) >>> g (x + 1)/(x^7 + x^5 - x^2 - 1) >>> g == s*p + t*q True - An example without a well defined gcd or xgcd on its base ring: - sage: # needs sage.rings.number_field sage: K = QuadraticField(5) sage: O = K.maximal_order() sage: R = PolynomialRing(O, 'x') sage: F = R.fraction_field() sage: x = F.gen(0) sage: x.gcd(x+1) 1 sage: x.xgcd(x+1) (1, 1/x, 0) sage: zero = F.zero() sage: zero.gcd(x) 1 sage: zero.xgcd(x) (1, 0, 1/x) sage: zero.xgcd(zero) (0, 0, 0) - >>> from sage.all import * >>> # needs sage.rings.number_field >>> K = QuadraticField(Integer(5)) >>> O = K.maximal_order() >>> R = PolynomialRing(O, 'x') >>> F = R.fraction_field() >>> x = F.gen(Integer(0)) >>> x.gcd(x+Integer(1)) 1 >>> x.xgcd(x+Integer(1)) (1, 1/x, 0) >>> zero = F.zero() >>> zero.gcd(x) 1 >>> zero.xgcd(x) (1, 0, 1/x) >>> zero.xgcd(zero) (0, 0, 0)