Ask Your Question

Revision history [back]

sage: L= [(1,2,3), (1/2, 4, 5), (-1, 0, 0)] sage: sum(vector(v) for v in L) (1/2, 6, 8)

When you type:

sage: (1,2,3)
(1, 2, 3)

You get a tuple, not a vector:

sage: type((1,2,3))
<type 'tuple'>

For tuple, the sum is the concatenation:

sage: (1,2,3)+(1/2, 4, 5)
(1, 2, 3, 1/2, 4, 5)

So to sum them as vectors, you have fist to transform them into vectors, as follows:

sage: L= [(1,2,3), (1/2, 4, 5), (-1, 0, 0)]
sage: sum(vector(v) for v in L)
(1/2, 6, 8)

8)