Message Boards Message Boards

0
|
5459 Views
|
5 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Listing off summations in Mathematica 11.1?

Posted 7 years ago

Hey, new here and to Mathematica, so sorry if I don't word this correctly - how would I go about getting a list of each summation previous to the upper bound? Example for clarity:

Sum[i, {i, 6}]
21

Instead of just giving 21, is there any way for it to give:

1, 3, 6, 10, 15, 21

And even better, if there would be any way to automatically put this into some sort of list or number each result, that would be wonderful.

POSTED BY: Dustin Deegan
5 Replies
In[3]:= Accumulate@Range[6]

Out[3]= {1, 3, 6, 10, 15, 21}
POSTED BY: Szabolcs Horvát
Posted 7 years ago
Accumulate[Cos[#] & /@ Range[6]]

Or numerically

N@Accumulate[Cos[#] & /@ Range[6]]
    N@Accumulate[#/2 & /@ Range[6]]
POSTED BY: Okkes Dulgerci

The general way without using complicated pure functions and Map, would simply be Table and Accumulate:

Accumulate[Table[i, {i, 6}]]

Which is very easy, compared to the syntax OP gives, and can also handle different iterator specifications...

POSTED BY: Sander Huisman
In[1]:= FoldList[Plus, Range[10]]

Out[1]= {1, 3, 6, 10, 15, 21, 28, 36, 45, 55}
Posted 7 years ago

Thank you! This is helpful - how would I do it for a certain function, say, Cos(x) or n/2?

POSTED BY: Dustin Deegan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract