I'm having a sum like this:
Sum[1 + x[i], {i, 1, n}]
Mathematica doesn't simplify it any more. What would I need to do so it translates it into:
n + Sum[x[i],{i,1,n}]
is a symbolic construct that represents the expression expr when the condition cond is True.
Details. Flatten "unravels" lists, effectively just deleting inner braces. Flatten[list,n] effectively flattens the top level in list n times.
Maybe this?
Distribute[Sum[1 + x[i], {i, 1, n}]]
which returns:
n + Sum[x[i], {i, 1, n}]
AFAIK Sum
simply won't give partial answers. But you can always split off the additive part manually, or semi-automatically. Taking your example,
In[1]:= sigma + (x[i] - X)^2 // Expand
Out[1]= sigma + X^2 - 2 X x[i] + x[i]^2
There's nothing we can do with the parts that contain x[i]
without knowing anything about x[i]
, so we just split off the rest:
In[2]:= Plus @@ Cases[%, e_ /; FreeQ[e, x[i]]]
Out[2]= sigma + X^2
In[3]:= Sum[%, {i, 1, n}]
Out[3]= n (sigma + X^2)
Unrelated: It is a good idea never to use symbols starting with capital letters to avoid conflicts with builtins. N
has a meaning already, and you shouldn't use it as a variable.
A quick and dirty way would be to use Thread
, so for example
Thread[Sum[Expand[sigma + (x[i] - X)^2], {i, 1, n}], Plus, 1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With