How to write the mathematic formulation of a pairwise sum?

226 Views Asked by At

In the normal summation, we can do this:

enter image description here

And that would sum a list X as such in Python:

>>> x = [1,2,3,4]
>>> sum([x_i for i,x_i in enumerate(x)])
10

Is there a mathematical symbol for pairwise sum? Like summing the first and second, then second and third, then third and forth? In Python:

>>> from itertools import tee, izip
>>> def pairwise(iterable):
...     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
...     a, b = tee(iterable)
...     next(b, None)
...     return zip(a, b)
...
>>> x = [1,2,3,4] 
>>> sum([x_i*x_j for x_i,x_j in pairwise(x)])
20

Would this math formulation be correct?

enter image description here

But there's a strange case in the formula above where i==n and i+1 doesn't exist.