# Ticket #8972: 8972_elliptic_doctest_fix.patch

File 8972_elliptic_doctest_fix.patch, 10.3 KB (added by Simon King, 13 years ago)

Fixing some remaining bugs of Laurent/power series arithmetic; fixing doc tests on elliptic curves.

• ## sage/modular/modform/find_generators.py

```# HG changeset patch
# User Simon King <simon.king@nuigalway.ie>
# Date 1275934215 -3600
# Node ID 556649e632322a8e97eaf43c62a7d7a8e35f0a35
Fixing some remaining bugs of Laurent/power series arithmetic; fixing doc tests on elliptic curves.

diff -r fe244f94ad95 -r 556649e63232 sage/modular/modform/find_generators.py```
 a K = v[0].parent().base_ring() V = K**n B = [V(g.padded_list(n)) for g in v] B = [V(g.padded_list(n) if hasattr(g,'padded_list') else g.power_series().padded_list(n)) for g in v] if basis: M = V.span_of_basis(B) else:
• ## sage/rings/laurent_series_ring_element.pyx

`diff -r fe244f94ad95 -r 556649e63232 sage/rings/laurent_series_ring_element.pyx`
 a """ return iter(self.__u) def exp(self): """ Return the exponential of ``self``. ASSUMPTION: ``self`` must in fact be a power series (non-negative valuation). EXAMPLES:: sage: R. = ZZ[[]] sage: p = t/(2+t) sage: p.exp() 1 + 1/2*t - 1/8*t^2 + 1/48*t^3 + 1/384*t^4 - 19/3840*t^5 + 151/46080*t^6 - 1091/645120*t^7 + 7841/10321920*t^8 - 56519/185794560*t^9 + 396271/3715891200*t^10 - 2442439/81749606400*t^11 + 7701409/1961990553600*t^12 + 145269541/51011754393600*t^13 - 4833158329/1428329123020800*t^14 + 104056218421/42849873690624000*t^15 - 2002667085119/1371195958099968000*t^16 + 37109187217649/46620662575398912000*t^17 - 679877731030049/1678343852714360832000*t^18 + 12440309297451121/63777066403145711616000*t^19 + O(t^20) sage: q = 2/(2*t+t^3) sage: q.exp() Traceback (most recent call last): ... ArithmeticError: self is a not a power series """ return self.parent()(self.power_series().exp()) def list(self): """ EXAMPLES:: def add_bigoh(self, prec): """ Add ``O(t^prec)`` to ``self``. INPUT: prec -- integer, the precision to obtain EXAMPLES:: sage: R. = LaurentSeriesRing(QQ) t^2 + t^3 + O(t^10) sage: f.add_bigoh(5) t^2 + t^3 + O(t^5) TEST: sage: P = QQ['t'] sage: p = P('2+t^3+4*t^15') sage: p + O(t^10)     # indirect doctest 2 + t^3 + O(t^10) """ if prec == infinity or prec >= self.prec(): return self u = self.__u.add_bigoh(prec - self.__n) try: u = self.__u.add_bigoh(prec - self.__n) except AttributeError: # perhaps self.__u is just a polynomial u = self.power_series().add_bigoh(prec - self.__n) return LaurentSeries(self._parent, u, self.__n,check=False) def degree(self): return self cpdef ModuleElement _rmul_(self, RingElement c): return LaurentSeries(self._parent, self.__u._rmul_(c), self.__n) # This is incorrect, since self.__u is not necessarily # an element of self.parent.power_series_ring() (though # there is a coercion). Hence, it is not safe to call # _rmul_ directly. #return LaurentSeries(self._parent, self.__u._rmul_(c), self.__n) return LaurentSeries(self._parent, self.__u*c, self.__n) cpdef ModuleElement _lmul_(self, RingElement c): return LaurentSeries(self._parent, self.__u._lmul_(c), self.__n) #return LaurentSeries(self._parent, self.__u._lmul_(c), self.__n) return LaurentSeries(self._parent, c*self.__u, self.__n) cpdef ModuleElement _ilmul_(self, RingElement c): self.__u *= c
• ## sage/rings/power_series_ring.py

`diff -r fe244f94ad95 -r 556649e63232 sage/rings/power_series_ring.py`
 a from sage.categories.pushout import CompletionFunctor return CompletionFunctor(self._names[0], self.default_prec()),  self._poly_ring() 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: R. = ZZ.quo(53)[[]] sage: FractionField(R) Laurent Series Ring in x over Ring of integers modulo 53 sage: 1/x in FractionField(R) True """ from sage.all import LaurentSeriesRing return LaurentSeriesRing(self.base().fraction_field(),self.variable_names()) def _coerce_impl(self, x): """ Return canonical coercion of x into self.
• ## sage/rings/power_series_ring_element.pyx

`diff -r fe244f94ad95 -r 556649e63232 sage/rings/power_series_ring_element.pyx`
 a try: u = ~(self>>v)    # inverse of unit part except: u = ~((self>>v)*self._parent.base().fraction_field()) R = self._parent.fraction_field()#_parent.laurent_series_ring() u = ~((self>>v)*self._parent.base().fraction_field()(1)) try: R = self._parent.fraction_field() except TypeError: # no integral domain R = self._parent.laurent_series_ring() from sage.all import LaurentSeries return LaurentSeries(R,u,-v,check=False)# R(u, -self.valuation()) TEST: The following tests against a bug that was fixed in The following tests against bugs that were fixed in ticket #8972:: sage: P. = ZZ[] sage: R. = P[[]] sage: 1/(t*x) 1/t*x^-1 sage: R. = PowerSeriesRing(ZZ.quo(15)) sage: t/(1+t) t + 14*t^2 + t^3 + 14*t^4 + t^5 + 14*t^6 + t^7 + 14*t^8 + t^9 + 14*t^10 + t^11 + 14*t^12 + t^13 + 14*t^14 + t^15 + 14*t^16 + t^17 + 14*t^18 + t^19 + 14*t^20 + O(t^21) sage: t/(3+t) Traceback (most recent call last): ... ZeroDivisionError: Inverse does not exist. """ F = self._parent.fraction_field() denom = denom_r if denom.is_zero(): raise ZeroDivisionError, "Can't divide by something indistinguishable from 0" try: F = self._parent.fraction_field() except: # Inverses may not always exist. So, we try, # and if the result exists, it will be in the # parent of self. return self* ~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
• ## sage/schemes/elliptic_curves/ell_wp.py

`diff -r fe244f94ad95 -r 556649e63232 sage/schemes/elliptic_curves/ell_wp.py`
 a True """ a_recip = 1/a a_recip = ~a # 1/a B =  b * a_recip C =  c * a_recip int_B = B.integral() J = int_B.exp() J_recip = 1/J J_recip = ~J # 1/J CJ = C * J int_CJ = CJ.integral() f =  J_recip * (alpha + int_CJ)
• ## sage/schemes/elliptic_curves/formal_group.py

`diff -r fe244f94ad95 -r 556649e63232 sage/schemes/elliptic_curves/formal_group.py`
 a return y + O(t**prec) w = self.w(prec+6) # XXX why 6? t = w.parent().gen() y = -(w**(-1)) + O(t**prec) y = O(t**prec) - (~w) #y = -(w**(-1)) + O(t**prec) self.__y = (prec, y) return self.__y[1]
`diff -r fe244f94ad95 -r 556649e63232 sage/schemes/elliptic_curves/padics.py`
`diff -r fe244f94ad95 -r 556649e63232 sage/structure/element.pyx`