Ask Your Question
1

Mapping abstract vector spaces

asked 2024-09-19 21:37:07 +0100

Xico_pezao gravatar image

This might be a very basic question, but I’ve been struggling with it for days and haven't found any helpful information in the Sage manual. I want to define two abstract vector spaces over a field k, and a linear map between them (and examine the kernel of this map).

Let R be the k-vector space with a basis {v_1, ..., v_n}, and let S be the k-vector space with a basis given by the pairs {[v_1, i_1], ..., [v_t, i_t]}, where each v_j is in R and i_j are some integers. I want to define the linear map f: S -> R that maps [v, i] to v. Let's take a simple example to illustrate the situation:

Let R be the vector space with the basis {u, v}, and let S be the space with the basis {[u, 7], [v, 8], [u+v, 9]}. The map f: S-> R is defined such that f([u, 7]) = u, f([v, 8]) = v, and f([u+v, 9]) = u+v. In this case, a possible basis for the kernel of f is {q = [u, 7] + [v, 8] - [u+v, 9]}. I would also like to recover the coordinates of the kernel vectors in S. For example, something like q.coefficients() = (1, 1, -1) in S.

I have defined the abstract variables v_i using the var(' ') function, but when I try to define the map (using module_morphism), it never works.

Any help would be greatly appreciated (including references to the manual).
Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2024-09-19 22:05:39 +0100

Here is one option, which uses CombinatorialFreeModule, which lets you define a vector space with a named basis. First, define a rational vector space with basis u,v:

sage: R.<u,v> = CombinatorialFreeModule(QQ)

Now define a second vector space with basis given by the "keys" (u,7), (v,8), (u+v, 9):

sage: S = CombinatorialFreeModule(QQ, basis_keys=[(u,7), (v,8), (u+v,9)])
sage: R
Free module generated by {'u', 'v'} over Rational Field
sage: S
Free module generated by {(u, 7), (v, 8), (u + v, 9)} over Rational Field
sage: S.basis()
Finite family {(u, 7): B[(u, 7)], (v, 8): B[(v, 8)], (u + v, 9): B[(u + v, 9)]}

Now define a linear transformation from S to R, which will take the basis element indexed by the pair (w, n) to w, which is the 0th element of this tuple:

sage: f = S.module_morphism(codomain=R, on_basis=lambda i: i[0])

Now compute a basis for the kernel:

sage: f.kernel_basis()
(B[(u, 7)] - B[(u + v, 9)] + B[(v, 8)],)
sage: K = f.kernel_basis()
sage: K[0]  # 0th element, which is the only element, in this basis
B[(u, 7)] - B[(u + v, 9)] + B[(v, 8)]
sage: K[0].coefficients()
[1, -1, 1]
edit flag offensive delete link more

Comments

Note that f.kernel() seems to give the wrong answer, I don't know why.

John Palmieri gravatar imageJohn Palmieri ( 2024-09-19 22:06:23 +0100 )edit

Thanks a lot for the answer! It helps a lot! Yes, I got the same incorrect result for f.kernel() with my attempts as well, but as you showed, we can work around it.

Xico_pezao gravatar imageXico_pezao ( 2024-09-20 14:54:41 +0100 )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

1 follower

Stats

Asked: 2024-09-19 21:37:07 +0100

Seen: 156 times

Last updated: Sep 19