Ask Your Question
0

Checking what the span is for a vector

asked 2020-07-16 00:20:50 +0200

whatupmatt gravatar image

updated 2023-05-19 22:07:56 +0200

FrédéricC gravatar image

Let's assume I have a vector called v1 and I have a matrix called Matrix.

Let us assume that the vector is in the span of the rows of Matrix. How would I know what the linear combination is? Here is what I do know. Let's assume this is a m by n matrix. I do know there is the span function. So

I can do something like make a list of vectors out of the Matrix. Say something like make an empty list ListofVectors=[].

i=0

while i< m:

ListofVectors.append(M[i])

i+=1

Now doing

v1 in span(ListofVectors)

will give me true assuming v1 is in the span. However, is there a function that tells me what the coefficients are for each term. For example, the vector v1=[3,2,1] for the ListofVectors being [1,1,1], [1,0,0], and [0,1,0] should give me coefficients 1,2,1 respectively as 1[1,1,1] + 2[1,0,0] + 1*[0,1,0] gives [3,2,1].

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-07-16 01:04:39 +0200

updated 2020-07-16 01:05:22 +0200

Looks like you are trying to solve the matrix equation x Matrix = v1 for x. Use Matrix.solve_left(v1).

sage: m = random_matrix(QQ, 2, 4)
sage: m
[   0    1    0 -1/2]
[  -1    0    0    0]
sage: v = 2*m[0] + m[1]
sage: v
(-1, 2, 0, -1)
sage: m.solve_left(v)
(2, 1)

Of course this need not have any solutions, and if it does have a solution, it may not be unique.

edit flag offensive delete link more

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: 2020-07-16 00:20:50 +0200

Seen: 1,030 times

Last updated: Jul 16 '20