# HG changeset patch
# User Simon King <simon.king@nuigalway.ie>
# 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
|
b
|
|
46 | 46 | sage: Frac(GF(5)['y']) |
47 | 47 | Fraction Field of Univariate Polynomial Ring in y over Finite Field of size 5 |
48 | 48 | |
49 | | Here the fraction field is not just the Laurent series ring, so you |
50 | | can't use the ``Frac`` notation to make the Laurent |
51 | | series ring. |
| 49 | After fixing ticket #8972, this also works if the base ring is not |
| 50 | a field. In this case, the ``Frac`` constructor returns the Laurent |
| 51 | series ring over the fraction field of the base ring. |
52 | 52 | |
53 | 53 | :: |
54 | 54 | |
55 | 55 | sage: Frac(ZZ[['t']]) |
56 | | Fraction Field of Power Series Ring in t over Integer Ring |
| 56 | Laurent Series Ring in t over Rational Field |
57 | 57 | |
58 | 58 | Laurent series rings are determined by their variable and the base |
59 | 59 | ring, and are globally unique. |
diff -r b863b0bd2d33 -r afbcfe010278 sage/rings/power_series_ring.py
a
|
b
|
|
783 | 783 | return self.__laurent_series_ring |
784 | 784 | |
785 | 785 | class PowerSeriesRing_domain(PowerSeriesRing_generic, integral_domain.IntegralDomain): |
786 | | pass |
787 | | |
| 786 | def fraction_field(self): |
| 787 | """ |
| 788 | Return the fraction field of this power series ring, which |
| 789 | is the same as the Laurent series ring over the fraction |
| 790 | field of the base ring of ``self``. |
| 791 | |
| 792 | EXAMPLE:: |
| 793 | |
| 794 | sage: R1.<x> = ZZ[[]] |
| 795 | sage: FractionField(R1) |
| 796 | Laurent Series Ring in x over Rational Field |
| 797 | sage: R2.<x> = GF(3)['t'][[]] |
| 798 | sage: 1/x in FractionField(R2) |
| 799 | True |
| 800 | """ |
| 801 | return self.laurent_series_ring().base_extend(self.base().fraction_field()) |
| 802 | |
788 | 803 | class PowerSeriesRing_over_field(PowerSeriesRing_domain): |
789 | 804 | def fraction_field(self): |
790 | 805 | """ |
diff -r b863b0bd2d33 -r afbcfe010278 sage/rings/power_series_ring_element.pyx
a
|
b
|
|
976 | 976 | t + O(t^21) |
977 | 977 | sage: (t^5/(t^2 - 2)) * (t^2 -2 ) |
978 | 978 | t^5 + O(t^25) |
| 979 | |
| 980 | TEST: |
| 981 | |
| 982 | The following tests against a bug that was fixed in |
| 983 | ticket #8972:: |
| 984 | |
| 985 | sage: P.<t> = ZZ[] |
| 986 | sage: R.<x> = P[[]] |
| 987 | sage: 1/(t*x) |
| 988 | 1/t*x^-1 |
979 | 989 | """ |
| 990 | F = self._parent.fraction_field() |
980 | 991 | denom = <PowerSeries>denom_r |
981 | 992 | if denom.is_zero(): |
982 | 993 | raise ZeroDivisionError, "Can't divide by something indistinguishable from 0" |
983 | | u = denom.valuation_zero_part() |
984 | | inv = ~u # inverse |
985 | 994 | |
986 | 995 | v = denom.valuation() |
987 | 996 | if v > self.valuation(): |
988 | | R = self._parent.laurent_series_ring() |
989 | | return R(self)/R(denom) |
| 997 | R = self._parent.laurent_series_ring().base_extend(self._parent.base().fraction_field()) |
| 998 | return F(R(self)/R(denom)) |
990 | 999 | |
991 | 1000 | # Algorithm: Cancel common factors of q from top and bottom, |
992 | 1001 | # then invert the denominator. We do the cancellation first |
993 | 1002 | # because we can only invert a unit (and remain in the ring |
994 | 1003 | # of power series). |
995 | 1004 | |
| 1005 | P_ext = self._parent.base_extend(denom_r.parent().base().fraction_field()) |
| 1006 | u = P_ext(denom.valuation_zero_part()) |
| 1007 | inv = ~u # inverse |
996 | 1008 | if v > 0: |
997 | 1009 | num = self >> v |
998 | 1010 | else: |
999 | 1011 | num = self |
1000 | | return num*inv |
| 1012 | return F(num*inv) |
1001 | 1013 | |
1002 | 1014 | def __mod__(self, other): |
1003 | 1015 | """ |