# HG changeset patch
# User Simon King
# Date 1273951205 3600
# Node ID afbcfe01027852f6b4ba28a411ab08c4a59c20fc
# Parent b863b0bd2d339b2740caf20783aabf3832531de8
Fixing various errors related with inverses of power series.
diff r b863b0bd2d33 r afbcfe010278 sage/rings/laurent_series_ring.py
 a/sage/rings/laurent_series_ring.py Fri May 07 09:16:09 2010 +0100
+++ b/sage/rings/laurent_series_ring.py Sat May 15 20:20:05 2010 +0100
@@ 46,14 +46,14 @@
sage: Frac(GF(5)['y'])
Fraction Field of Univariate Polynomial Ring in y over Finite Field of size 5
 Here the fraction field is not just the Laurent series ring, so you
 can't use the ``Frac`` notation to make the Laurent
 series ring.
+ After fixing ticket #8972, this also works if the base ring is not
+ a field. In this case, the ``Frac`` constructor returns the Laurent
+ series ring over the fraction field of the base ring.
::
sage: Frac(ZZ[['t']])
 Fraction Field of Power Series Ring in t over Integer Ring
+ Laurent Series Ring in t over Rational Field
Laurent series rings are determined by their variable and the base
ring, and are globally unique.
diff r b863b0bd2d33 r afbcfe010278 sage/rings/power_series_ring.py
 a/sage/rings/power_series_ring.py Fri May 07 09:16:09 2010 +0100
+++ b/sage/rings/power_series_ring.py Sat May 15 20:20:05 2010 +0100
@@ 783,8 +783,23 @@
return self.__laurent_series_ring
class PowerSeriesRing_domain(PowerSeriesRing_generic, integral_domain.IntegralDomain):
 pass

+ def fraction_field(self):
+ """
+ Return the fraction field of this power series ring, which
+ is the same as the Laurent series ring over the fraction
+ field of the base ring of ``self``.
+
+ EXAMPLE::
+
+ sage: R1. = ZZ[[]]
+ sage: FractionField(R1)
+ Laurent Series Ring in x over Rational Field
+ sage: R2. = GF(3)['t'][[]]
+ sage: 1/x in FractionField(R2)
+ True
+ """
+ return self.laurent_series_ring().base_extend(self.base().fraction_field())
+
class PowerSeriesRing_over_field(PowerSeriesRing_domain):
def fraction_field(self):
"""
diff r b863b0bd2d33 r afbcfe010278 sage/rings/power_series_ring_element.pyx
 a/sage/rings/power_series_ring_element.pyx Fri May 07 09:16:09 2010 +0100
+++ b/sage/rings/power_series_ring_element.pyx Sat May 15 20:20:05 2010 +0100
@@ 976,28 +976,40 @@
t + O(t^21)
sage: (t^5/(t^2  2)) * (t^2 2 )
t^5 + O(t^25)
+
+ TEST:
+
+ The following tests against a bug that was fixed in
+ ticket #8972::
+
+ sage: P. = ZZ[]
+ sage: R. = P[[]]
+ sage: 1/(t*x)
+ 1/t*x^1
"""
+ F = self._parent.fraction_field()
denom = denom_r
if denom.is_zero():
raise ZeroDivisionError, "Can't divide by something indistinguishable from 0"
 u = denom.valuation_zero_part()
 inv = ~u # inverse
v = denom.valuation()
if v > self.valuation():
 R = self._parent.laurent_series_ring()
 return R(self)/R(denom)
+ R = self._parent.laurent_series_ring().base_extend(self._parent.base().fraction_field())
+ return F(R(self)/R(denom))
# Algorithm: Cancel common factors of q from top and bottom,
# then invert the denominator. We do the cancellation first
# because we can only invert a unit (and remain in the ring
# of power series).
+ P_ext = self._parent.base_extend(denom_r.parent().base().fraction_field())
+ u = P_ext(denom.valuation_zero_part())
+ inv = ~u # inverse
if v > 0:
num = self >> v
else:
num = self
 return num*inv
+ return F(num*inv)
def __mod__(self, other):
"""