sum for sequences?

Neil Cerutti neilc at norwich.edu
Tue Apr 6 16:51:27 CEST 2010


On 2010-04-06, Albert van der Horst <albert at spenarnc.xs4all.nl> wrote:
> To a mathematician sum(set) suggest that the order of summation
> doesn't matter. (So I wouldn't use sum for concatenating
> lists.) Harshly, sum() should be used only for operator + both
> associative and commutative.
>
> Now for floating point numbers the order of summation is
> crucial, not commutative  (a+b)+c <> a+(b+c). So the obvious
> thing for someone versed in numerical computing do is looking
> whether sum() gives any guarantees for order and whether there
> may be a special sum() for floating point. (This is not very
> realistic, because such a person would have skimmed the math
> library a long time ago, but anyway.)

I'm convinced by this argument. I just have to be a mathematician
and a computer scientist skilled in numerical computing. No
problem! Just a *few more years* of education and I'll be ready
for summing things in Python. ;)

-- 
Neil Cerutti



More information about the Python-list mailing list