First time here? Check out the FAQ!

Ask Your Question
1

Coordinates in a free submodule

asked 4 years ago

jraimbau gravatar image

updated 4 years ago

slelievre gravatar image

I am working with free ℤ-modules that are presented a submodules of ℤ^n, for example:

A = Matrix([[1, 1, 1]])
V = A.right_kernel()

When creating this ℤ-module Sage computes a basis (in this case [(1, 0, -1), (0, 1, -1)]).

I can also create elements of V as follows :

v = V([2, -1, -1])

but then I could not find a way to get the coordinates of v in the basis of V.

Is there a function somewhere in Sage that does this?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

slelievre gravatar image

updated 4 years ago

Using dot-tab exploration on v and on V reveals a solution.

Maybe slightly surprisingly at first, one can ask V for the coordinates of v.

Let us replay the whole sequence.

Define a matrix, compute its kernel, display it.

sage: A = Matrix([[1, 1, 1]])
sage: V = A.right_kernel()
sage: V
Free module of degree 3 and rank 2 over Integer Ring
Echelon basis matrix:
[ 1  0 -1]
[ 0  1 -1]

Create a vector as an element of the kernel.

sage: v = V([2, -1, -1])
sage: v
(2, -1, -1)
sage: v in V
True

Try typing v. then hitting the TAB key. Same with V. and TAB key.

There are promising methods coordinates and coordinate_vector for V.

One gives the coordinates as a list:

sage: V.coordinates(v)
[2, -1]

The other one gives the coordinates as a vector:

sage: V.coordinate_vector(v)
(2, -1)

Check the result with the linear_combination_of_basis method:

sage: V.linear_combination_of_basis((2, -1))
(2, -1, -1)
Preview: (hide)
link

Comments

Thank you Samuel! (I tried the dot method but with v. and not V, so it goes).

jraimbau gravatar imagejraimbau ( 4 years ago )

It might be worth improving Sage by adding an element method in addition to the parent method, so that one could do v.something(V) and not only V.something(V).

slelievre gravatar imageslelievre ( 4 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 4 years ago

Seen: 315 times

Last updated: Dec 16 '20