HP Forums
Problems with the command cumSum and Workaround - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Problems with the command cumSum and Workaround (/thread-3814.html)



Problems with the command cumSum and Workaround - Eddie W. Shore - 05-11-2015 07:50 PM

Example: store {10, 20, 10} to L1

cumSum(L1):

sometimes returns {10, 40, Nan}
sometimes returns {10, 30, 40} (the right answer)
sometimes causes the calcualtor to crash

Software Version 6975


Here is a possible workaround:
CSUM(list)
BEGIN
LOCAL k;
FOR k FROM 2 TO SIZE(list) DO
list[k]:=list[k]+list[k-1];
END;
RETURN list;
END;

CSUM({10,20.10}) returns {10,30,40}


RE: Problems with the command cumSum and Workaround - Marcio - 05-11-2015 08:42 PM

I couldn't reproduce the errors and the crash you're reporting!


RE: Problems with the command cumSum and Workaround - JimS - 05-11-2015 08:54 PM

Hi Eddie'

I could not reproduce your error. Tried in HOME mode and CAS with various values in L1.


RE: Problems with the command cumSum and Workaround - Terje Vallestad - 05-11-2015 09:04 PM

eddie,

I tried 20 times in CAS and same in Home but could not reproduce the error. Textbook setting, 6975 SW on the actual calculator.

Cheers, Terje


RE: Problems with the command cumSum and Workaround - StephenG1CMZ - 12-30-2017 05:17 PM

One oddity I have just noted is that whereas cumSum normally returns a list, the built-in cumSum({}) returns numerical 0 instead - a result of a different type.
I am not certain what the correct result should be, but I would expect/hope for either {} or {0}, not 0.


RE: Problems with the command cumSum and Workaround - parisse - 12-30-2017 07:13 PM

I have implemented cumSum for TI compatibility, and it returns 0 for an empty list.