Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to handle integers in the symbolic ring?

Consider the script:

from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
assume(abs(x)<1)
M = [SR(1), x, x^2 + 1, x^3 + 3*x, x^4 + 6*x^2 + 2, x^5 + 10*x^3 + 10*x]
for k in range(len(M)):
    p = symbolic_sum(x^j*M[k](x=j), j, 0, oo)
    F = p.partial_fraction()
    print [k], [numerator(f) for f in F.operands()]

What I get is:

[0] [1, -1]
[1] [1, 1]
[2] [-2, -3, -2]
[3] [4, 10, 12, 6]
[4] [-9, -33, -62, -60, -24]
[5] [21, 111, 300, 450, 360, 120]

What I expect in the first line is

[0] [-1]

But more generally: Is there a way to get around this darned SR(1) in the first place? This problem appears over and over again and forces to be handled as a separate case. The result is often a mess, as it is the case when the above array M is created by a procedure.

Moreover this workaround does not fit well with other functions as can be seen for example from the bug above.