I believe the plain answer is that it's just too complicated for the currecnt system to make the substitutions required.
With that said, there might be an issue with expansion of summation here.
I managed to get the correct answer by changing the Sum
s in the expand
output with summation
s, see console session below.
The reason which I believe made the last one possible, is that summation(x, (i, 0, N))
evaluates to x*(N + 1)
(effect of the summation
function), while the Sum(x, (i, 0, N))
returned by the expansion remains a simple Sum
object, therefore no substitution made for it after the inner expansion in the solve
function.
>>> from sympy import *
>>>
>>> i, N, x, y = symbols("i, N, x, y")
>>> eq = summation(x + y(i), (i, 0, N))
>>>
>>> expand(eq)
Sum(x, (i, 0, N)) + Sum(y(i), (i, 0, N))
>>>
>>> solve(summation(x, (i, 0, N)) + summation(y(i), (i, 0, N)), x)
[Sum(-y(i), (i, 0, N))/(N + 1)]
- By the way, the solution is divided by N + 1, since the summation contains 0 and N (thus, 0 to N is N + 1 times).