Ask Your Question
1

Coordinates in a free submodule

asked 2020-12-16 18:06:25 +0200

jraimbau gravatar image

updated 2020-12-16 18:57:27 +0200

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-12-16 19:05:55 +0200

slelievre gravatar image

updated 2020-12-16 21:16:39 +0200

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)
edit flag offensive delete link more

Comments

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

jraimbau gravatar imagejraimbau ( 2020-12-16 19:41:44 +0200 )edit

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 ( 2020-12-16 21:19:00 +0200 )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

Stats

Asked: 2020-12-16 18:06:25 +0200

Seen: 40 times

Last updated: Dec 16 '20