3
$\begingroup$

Is there a way to have Mathematica simplify long expressions involving sums of variables into expressions using a sum function? Suppose I have something like this:

Subscript[x, 1] + Subscript[x, 2] + Subscript[x, 3] + Subscript[x, 
  4] + Subscript[x, 5] 

I would like to get the following output after simplification:

Sum[Subscript[x, i], {i, 1, 5}] 
$\endgroup$
  • $\begingroup$ In fact, the reverse happens by default. Sum[Subscript[x, i], {i, 5}] returns Subscript[x, 1] + Subscript[x, 2] + Subscript[x, 3] + Subscript[x, 4] + Subscript[x, 5]. The same is true for Sum[x[i], {i, 5}]. $\endgroup$ – bbgodfrey Jun 7 '15 at 4:12
  • $\begingroup$ Yes, and this is particularly unfortunate when differentiating or integrating sums, like D[Sum[x^i, {i, 1, 10}], x]. In some cases it would be nice if sums weren't expanded automatically. $\endgroup$ – Peter Jun 8 '15 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.