from functools import reduce
import operator


def _vector_add(*vecs):
    """For any number of length-n vectors, pairwise add the entries, e.g. for
    x = (x_0, ..., x_{n-1}), y = (y_0, ..., y_{n-1}),
    xy = (x_0+y_0, x_1+y_1, ..., x_{n-1}+y{n-1})."""
    assert(len(set(map(len, vecs))) == 1)
    return [reduce(operator.add, a, 0) for a in zip(*vecs)]