1 | initial version |

Your unexpectedd result is not about `SR(1)`

, it comes from the fact that, when `k=0`

, `F`

equals `-1/(x - 1)`

, which is not a sum, but a product of `-1`

with `-1/(x - 1)`

, hence there are two operands for the `mul`

operator. If you want to see it as the sum of a single fraction, a possible trick could be to add an independent variable `y`

to ensure that you do not have a trivial sum, and then remove it from the list of operands:

```
from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
y = SR.var('y')
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() + y
fractions = F.operands()
fractions.remove(y)
print [k], [numerator(f) for f in fractions]
```

You should get what you expected:

```
[0] [-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]
```

2 | No.2 Revision |

Your unexpectedd result is not about `SR(1)`

, it comes from the fact that, when `k=0`

, `F`

equals `-1/(x - 1)`

, which is not a sum, but a product of `-1`

with

, hence there are two operands for the ~~-1/(x ~~1/(x - 1)`mul`

operator. If you want to see it as the sum of a single fraction, a possible trick could be to add an independent variable `y`

to ensure that you do not have a trivial sum, and then remove it from the list of operands:

```
from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
y = SR.var('y')
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() + y
fractions = F.operands()
fractions.remove(y)
print [k], [numerator(f) for f in fractions]
```

You should get what you expected:

```
[0] [-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]
```

3 | No.3 Revision |

Your unexpectedd result is not about `SR(1)`

, it comes from the fact that, when `k=0`

, `F`

equals `-1/(x - 1)`

, which is not a sum, but a product of `-1`

with `1/(x - 1)`

, hence ~~there are ~~you got the two operands ~~for ~~of the `mul`

operator. If you want to see ~~it ~~`-1/(x - 1)`

as the sum of a single fraction, a possible trick could be to add an independent variable `y`

to ensure that you do not have a trivial sum, and then remove it from the list of operands:

```
from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
y = SR.var('y')
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() + y
fractions = F.operands()
fractions.remove(y)
print [k], [numerator(f) for f in fractions]
```

You should get what you expected:

```
[0] [-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]
```

4 | No.4 Revision |

Your unexpectedd result is not about `SR(1)`

, it comes from the fact that, when `k=0`

, `F`

equals `-1/(x - 1)`

, which is not a sum, but a product of `-1`

with `1/(x - 1)`

, hence you got the two operands of the `mul`

operator. If you want to see `-1/(x - 1)`

as the sum of a single fraction, a possible trick could be to add an independent variable `y`

to ensure that you do not have a trivial sum, and then remove it from the list of operands:

```
from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
y = SR.var('y')
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() + y
```~~fractions = F.operands()
fractions.remove(y)
~~print [k], [numerator(f) for f in ~~fractions]
~~F.operands() if f != y]

You should get what you expected:

```
[0] [-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]
```

5 | No.5 Revision |

Your unexpectedd result is not about `SR(1)`

, it comes from the fact that, when `k=0`

, `F`

equals `-1/(x - 1)`

, which is not a sum, but a product of `-1`

with `1/(x - 1)`

, hence you got the two operands of the `mul`

operator. If you want to see `-1/(x - 1)`

as the sum of a single fraction, a possible trick could be to add an independent variable `y`

to ensure that you do not have a trivial sum, and then remove it from the list of operands:

```
from sage.calculus.calculus import symbolic_sum
x, j = SR.var('x, j')
y = SR.var('y')
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() + y
print [k], [numerator(f) for f in F.operands() if f != y]
```

You should get what you expected:

```
[0] [-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]
```

That said, if you want to avoid to have to substitute `x`

with `j`

in `1`

(which requires using `SR(1)`

and not `ZZ(1)`

for which the substitution is not defined), why not using `j`

directly in `M`

?

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

While we are at it, instead of counting elements of `M`

, iterate over the integer `k`

, and use the `k`

-th element of `M`

, note that you can enumerate elements of `M`

directly:

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

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.