# Last@Accumulate not giving same result as Total

If I run the code:

arr = Table[0.979, 249];
Last@Accumulate[arr] - Total[arr]


on Mathematica 11.0 (Windows), I get the result 1.53477*10^-12. I should instead be getting a result of 0, since Accumulate's last element should be the total of the array.

Also, this only happens when the array's length length is less than 250. The difference between the Total and Acumulate also seems to vary depending on the value of the elements inside the array, and for some values, Total and Accumulate will give the same result.

Something such as ListPlot@Table[(Accumulate[Table[a, 249]] - Total[Table[a, 249]])[[-1]], {a, 0, 1, 0.1}] shows an intresting graph of the difference between the two for various values:

My questions are:

• Why is this happening? Is this a bug?
• Why doesn't this happen for arrays larger than 250?
• I need Accumulate to give me the same result as Total, so I'm currently zero-padding my arrays to 250 as a workaround. Is there a better soultion instead?

Edit: Even though Last@Accumulate[arr] - Total[arr] is 1.53477*10^-12, Table[Last@Accumulate[arr] - Total[arr], 250] gives an array of 0s (Table[1.53477*10^-12, 250] does not).

• The 250 limit has to do with whether Table returns a packed array. Try arr = DeveloperToPackedArray[arr]. I would have guessed that the different result is simply due to the summation being done in a different order, but I don't understand how this relates to the array being packed. – Szabolcs Sep 21 '16 at 4:44
• ... and use Method->"CompensatedSummation"` for both and compare... – ciao Sep 21 '16 at 4:47