Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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$$

And:

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!

share|improve this question
    
This question is off-topic here. Please see FAQ. –  Sasha Nov 17 '11 at 20:41
1  
I think this question is on-topic. Please consider this my vote against closure. –  Srivatsan Nov 17 '11 at 21:01
    
@OP: What is your desired output? –  Listing Nov 17 '11 at 21:54
3  
@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 –  Phira Nov 17 '11 at 23:19
1  
@Phira Thanks. Sure I will. –  Ivan Z. Siu Nov 18 '11 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]]
        expandSum[%]
        factorSum[%]

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]}}
share|improve this answer
    
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. –  Ivan Z. Siu Nov 18 '11 at 4:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.