Ask Your Question

Revision history [back]

Python uses negative indices to index from the end.

So for a 3 by 3 matrix, you can think of the indices as 0, 1, 2 or equivalently -3, -2, -1.

In other words you could also think of them as 0, 1, -1.

sage: m = matrix(3, [1 .. 9])
sage: m
[1 2 3]
[4 5 6]
[7 8 9]
sage: m[-1, -1]
9
sage: m[-1, 1]
8
sage: m[1, -1]
6