I want to solve an equation with sum in Mathematica, e.g.,

$$\sum _i \frac{a_i}{x}=1$$

But when I input this:

Solve[Sum[Subscript[a, i]/x, i] == 1, x]

Mathematica will tell me:

Solve::nsmet : This system cannot be solved with the methods available to Solve.

If I remove the $x$ from the equation like this:

$$\frac{\sum _i a_i}{x}=1$$


Solve[Sum[Subscript[a, i], i]/x == 1, x]

Then Mathematica can actually solve it. But this seems a bit troublesome and strange to me. So am I using it incorrectly? What should I input in this case, thanks!

  • $\begingroup$ This question is off-topic here. Please see FAQ. $\endgroup$
    – Sasha
    Nov 17, 2011 at 20:41
  • 1
    $\begingroup$ I think this question is on-topic. Please consider this my vote against closure. $\endgroup$
    – Srivatsan
    Nov 17, 2011 at 21:01
  • $\begingroup$ @OP: What is your desired output? $\endgroup$
    – Listing
    Nov 17, 2011 at 21:54
  • 3
    $\begingroup$ @IvanZ.Siu It is not surprising that mathematica cannot handle this, since it is not clear at all what mathematica should do to a sum with unspecified summation range in general. Please consider supporting the proposals for a mathematica stackexchange site: area51.stackexchange.com/proposals/15787/mathematica $\endgroup$
    – Phira
    Nov 17, 2011 at 23:19
  • 1
    $\begingroup$ @Phira Thanks. Sure I will. $\endgroup$
    – Ivan Xiao
    Nov 18, 2011 at 4:56

1 Answer 1


Mathematica does not have the (user facing) ability to do manipulations of unevaluated sums or integrals. However, simple cases are easily programmed by hand.

I assume that the indefinite sum that you're really interested in is more complicated than the example you provided. Here's some quick code for taking common factors out of sums and expanding sums. You can write similar code to reverse these operations.

factorSum[expr_] := expr /. Sum[x_, i_] :> Module[
    {factx = Factor[x], common, 
     ii = If[Head[i] === List, First[i], i]},
    common = If[Head[factx] === Times, Select[factx, FreeQ[#, ii]&], 1];
    common Sum[factx/common, i]]
expandSum[expr_] := expr /. Sum[x_, i_] :> Module[
    {expandx = Expand[x], ii = If[Head[i] === List, First[i], i]},
    If[Head[expandx] === Plus, 
     Total@Table[Sum[term, i], {term, List @@ expandx}], Sum[x, i]]]

And here it is in action (you can replace the indefinite i with a more definite {i, n1, n2} and it still works):

In[3]:= factorSum[Sum[a[i]*x*y*b^i + y*c[i], i]]

Out[3]= y*Sum[b^i*x*a[i] + c[i], i]

Out[4]= y*(Sum[b^i*x*a[i], i] + Sum[c[i], i])

Out[5]= y*(x*Sum[b^i*a[i], i] + Sum[c[i], i])

Note that it is a little slow, because every time a new Sum is produced, Mathematica tries to see if it can evaluate it. If you were serious about implementing formal manipulations of sums and integrals, you'd have to define new symbolicSum-type objects or turn off the built in behaviour while your code is running.

Anyway, here's your original problem:

In[6]:= Solve[factorSum[Sum[Subscript[a, i]/x, i]] == 1, x]
Out[6]= {{x -> Sum[Subscript[a, i], i]}}
  • $\begingroup$ Yes I do have a much more complicated problem to solve. I am just trying to show a minimal example. So basically Mathematica cannot handle unevaluated sums. I do wish I can achieve things in a symbolic way. Thanks a lot. $\endgroup$
    – Ivan Xiao
    Nov 18, 2011 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .