Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to get

   s[n_]:=Sum[1/2^k,{k,1,n}]

to show me the actual terms involved in the $n$th partial sum and not just the sum itself. I've tried Expand, Apart, etc. to no avail. Ideas?

Edit based on early comments: Is it necessary to use Table to accomplish this rather than some algebraic command applied to s[n] or some option of Sum?

share|improve this question
    
s[n_] := Row[Riffle[Table[1/2^k, {k, 1, n}], "+"]] then? –  J. M. Nov 9 '12 at 16:01
1  
Or s[n_Integer?Positive] := Array[1/2^# &, n, 1, Defer[Plus[##]] &] allowing you to copy/paste the result and evaluate it. –  Sasha Nov 9 '12 at 16:04
4  
@J.M. I am sure you are aware of the shortcut Row[Table[1/2^k, {k, 1, n}], "+"] to your code. –  Sasha Nov 9 '12 at 16:05
    
@Sasha, not until you brought it up, actually; thanks! –  J. M. Nov 9 '12 at 16:09
2  
@J.M. Row[list,s] inserts s as a separator between successive elements. Damn! there is too much functionality to dig up –  belisarius Nov 9 '12 at 18:37

1 Answer 1

up vote 5 down vote accepted

If working in the notebook the following

s[n_Integer?Positive] := Array[1/2^# &, n, 1, Defer[Plus[##]] &]

will produce an expression that can be copied, pasted and would evaluate as if the sum was explicitly typed in.

Alternatively you can build a visual resemblance of the sum using Row:

s[n_Integer?Positive] := Row[Table[1/2^k, {k, 1, n}], "+"]
share|improve this answer
1  
That first one is so cool! ;-) –  JohnD Nov 10 '12 at 19:00

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.