Ask Your Question

accessing the components of a vector

asked 2013-09-21 12:06:35 -0600

anonymous user


Is there a command in Sage that allows me to access the individual components of a vector? For example, suppose I've defined a vector like a=vector([1,2,3]). I want a command like "a.1" that returns the first component of the vector, so in this case I would want a.1 to return 1. Is there a command like this in Sage? Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-09-21 12:15:28 -0600

minopret gravatar image

You can use Python sequence indexing syntax, for which the index numbers start at zero: a=vector([1,2,3]);a[0] returns 1.

edit flag offensive delete link more


Thank you!

strangelove1221 gravatar imagestrangelove1221 ( 2013-09-21 12:27:23 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-09-21 12:06:35 -0600

Seen: 2,006 times

Last updated: Sep 21 '13