Partial Sums in Spreadsheets

1,359 views
Skip to first unread message

EulerRocks

unread,
Jun 18, 2011, 9:34:36 PM6/18/11
to tins...@googlegroups.com
Hello all.   I am very excited to be a part of this user group as we are using the Nspires in our district heavily next year.   I had a quick question about partial sums in the spreadsheet page on the Nspire.

On another page, I have allowed the user to define the number of terms "n" in a sequence stored as a variable.  Then on a spreadsheet page, I have a sequence an generated recursively using the "SeqGen" command consisting of exactly "n" terms as previously defined.  In the next column I would like to find the partial sums of these terms, namely S1 = a1, S2 = a1 + a2, ... , Sn = a1 + a2 + ...  + an.

I could definitely do this iteratively by adding the new term to the previous partial sum, but then when the number of terms, n, changes, this will not work.  My question is how to does one construct a sequence of partial sums from a sequence whose number of terms may change as a variable?

Any help would be much appreciated.
Chris

Jim Fullerenex

unread,
Jun 18, 2011, 9:42:01 PM6/18/11
to tins...@googlegroups.com
I believe the correct function you should use is the built-in cumulative sum, seems to be cumultsum() (I don't have hh with me right now, so just pray my memory serves.) For its detail usage check up the catalogue. Hope can help. :)

2011/6/19 EulerRocks <bologne...@gmail.com>

--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
http://lafacroft.com/archive/nspire.php



--
Cheers,
Jimmy Fullerenex

EulerRocks

unread,
Jun 18, 2011, 10:11:38 PM6/18/11
to tins...@googlegroups.com
Excellent.  Cumulativesum(list) did the trick!  Thanks.

Nelson Sousa

unread,
Jun 19, 2011, 1:19:34 PM6/19/11
to tins...@googlegroups.com

Interactively works, but it's a pain. Plus, as the list grows it only gets worse.

Here's an alternative: column A is stored as variable list; define column B as 

=seq(sum(left(list,i)),i,1,dim(list))

Warning: the complexity grows with n^2, so keep your lists small (don't go define list with 1000 entries)

--
Nelson
--

Jim Fullerenex

unread,
Jun 19, 2011, 7:44:45 PM6/19/11
to tins...@googlegroups.com
How's the performance of cumulativesum() compared to the user-defined alternative? Why create an additional function while built-in can solve the problem literally the same?  I believe built-ins should be more efficient in most cases.
Cheers,
Jimmy Fullerenex



2011/6/20 Nelson Sousa <nso...@gmail.com>

Nelson Sousa

unread,
Jun 20, 2011, 5:42:51 AM6/20/11
to tins...@googlegroups.com
because I didn't think of cumulativesum and didn't read your message
before posting mine. :)
Cumulative sum probably has the same complexity and is very likely to
be a similar algorithm.

Nelson

Reply all
Reply to author
Forward
0 new messages