Ask Your Question

Revision history [back]

When you write a=[(1,0,0)], a becomes the name of a list that contains a single element, which is the tuple (1,0,0), list and tuples are Python objects.

Note that tuples can be added, but since most Python programmers are not mathematicians, the most useful way to define addition is by concatenation:

sage: (1,0,0) + (3,4)
(1, 0, 0, 3, 4)
sage: (1,0,0) + ('a','b')
(1, 0, 0, 'a', 'b')

For tuples and lists, subtraction is not defined:

sage: (1,0,0) - (3,4,4)
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'

So, it s better to define points in a vector space as vectors themselves, and the vector joining the two points is just their difference:

sage: a = vector((1,0,0))
sage: b = vector((0,-1,0))
sage: u = b-a
sage: u
(-1, -1, 0)