#1302: [with patch, with two positive reviews] bug in laurent_series integration
------------------------------------+--------------------------
Reporter: was | Owner: rishi
Type: defect | Status: closed
Priority: major | Milestone: sage-2.9.2
Component: basic arithmetic | Resolution: fixed
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
------------------------------------+--------------------------
Changes (by chapoton):
* upstream: => N/A
Old description:
> {{{
> On Nov 28, 2007 10:43 AM, Jennifer S. Balakrishnan <> wrote:
> > I'm trying to integrate a list of Laurent series, and it seems that
> > once the list has more than 4 elements, Sage gets upset:
>
> The problem is:
>
> sage: A.<t> = LaurentSeriesRing(QQ)
> sage: (-2*t^(-4) + O(t^8)).integral()
> Traceback (most recent call last):
> ...
> IndexError: list index out of range
>
> This is because of this code in rings/laurent_series_ring_element.pyx
> not
> being coded correctly around line 880:
> if n < 0:
> v = [a[i]/(n+i+1) for i in range(-1-n)] + [0]
> else:
> v = []
> v += [a[i]/(n+i+1) for i in range(max(-n,0), len(a))]
> try:
>
> So you should fix that and submit a patch :-).
>
> William
>
>
> >
> > sage: A.<t> = LaurentSeriesRing(QQ)
> > sage: B = [-2*t^4 + O(t^16), -2*t^2 + O(t^14), -2 + O(t^12), -2*t^-2 +
> > O(t^10), -2*t^-4 + O(t^8), -2*t^-6 + O(t^6)]
> > sage: for i in range(6):
> > ....: B[i] = integral(B[i])
> > ....:
> >
> ---------------------------------------------------------------------------
> > <type 'exceptions.IndexError'> Traceback (most recent call
> last)
> >
> > /home/jen/<ipython console> in <module>()
> >
> > /home/jen/sage-2.8.13-use_this_on_sage_dot_math-
> x86_64-Linux/local/lib/python2.5/site-packages/sage/misc/functional.py
> > in integral(x, *args, **kwds)
> > 449 """
> > 450 if hasattr(x, 'integral'):
> > --> 451 return x.integral(*args, **kwds)
> > 452 else:
> > 453 from sage.calculus.calculus import SR
> >
> > /home/jen/laurent_series_ring_element.pyx in
> > sage.rings.laurent_series_ring_element.LaurentSeries.integral()
> >
> > <type 'exceptions.IndexError'>: list index out of range
> > sage: B
> >
> > [-2/5*t^5 + O(t^17),
> > -2/3*t^3 + O(t^15),
> > -2*t + O(t^13),
> > 2*t^-1 + O(t^11),
> > -2*t^-4 + O(t^8), <================== stopped integrating here
> > -2*t^-6 + O(t^6)]
> >
> > What's going on?
> >
> > Jen
> >
> }}}
New description:
{{{
On Nov 28, 2007 10:43 AM, Jennifer S. Balakrishnan <> wrote:
> I'm trying to integrate a list of Laurent series, and it seems that
> once the list has more than 4 elements, Sage gets upset:
The problem is:
sage: A.<t> = LaurentSeriesRing(QQ)
sage: (-2*t^(-4) + O(t^8)).integral()
Traceback (most recent call last):
...
IndexError: list index out of range
This is because of this code in rings/laurent_series_ring_element.pyx not
being coded correctly around line 880:
if n < 0:
v = [a[i]/(n+i+1) for i in range(-1-n)] + [0]
else:
v = []
v += [a[i]/(n+i+1) for i in range(max(-n,0), len(a))]
try:
So you should fix that and submit a patch :-).
William
>
> sage: A.<t> = LaurentSeriesRing(QQ)
> sage: B = [-2*t^4 + O(t^16), -2*t^2 + O(t^14), -2 + O(t^12), -2*t^-2 +
> O(t^10), -2*t^-4 + O(t^8), -2*t^-6 + O(t^6)]
> sage: for i in range(6):
> ....: B[i] = integral(B[i])
> ....:
>
---------------------------------------------------------------------------
> <type 'exceptions.IndexError'> Traceback (most recent call
last)
>
> /home/jen/<ipython console> in <module>()
>
> /home/jen/sage-2.8.13-use_this_on_sage_dot_math-
x86_64-Linux/local/lib/python2.5/site-packages/sage/misc/functional.py
> in integral(x, *args, **kwds)
> 449 """
> 450 if hasattr(x, 'integral'):
> --> 451 return x.integral(*args, **kwds)
> 452 else:
> 453 from sage.calculus.calculus import SR
>
> /home/jen/laurent_series_ring_element.pyx in
> sage.rings.laurent_series_ring_element.LaurentSeries.integral()
>
> <type 'exceptions.IndexError'>: list index out of range
> sage: B
>
> [-2/5*t^5 + O(t^17),
> -2/3*t^3 + O(t^15),
> -2*t + O(t^13),
> 2*t^-1 + O(t^11),
> -2*t^-4 + O(t^8), <================== stopped integrating here
> -2*t^-6 + O(t^6)]
>
> What's going on?
>
> Jen
>
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/1302#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.