# Revision history [back]

Please always mention the own effort to solve the problem. Well, in this case it is simpler to deliver the solution then to give a hint in a comment pointing to the particularity of the situation...

OP gives us:

v1 = vector([1,  0,  2,  2,  0,  4,  4,  0,  10])
v2 = vector([0,  1,  1,  3,  3,  2,  3,  2,   5])
v3 = vector([1,  2,  4,  8,  6,  8, 10,  4,  20])
v4 = vector([1,  2,  0,  4, 10,  0,  6, 20,   0])
v5 = vector([0,  1,  3,  3,  5, 10,  9, 10,  11])
v6 = vector([1,  4,  6, 10, 20, 20, 24, 40,  22])
v7 = vector([1, -1,  1, -1, -3,  2,  1, -2,   5])
v8 = vector([0,  1, -2,  1, -2,  0,  4,  0,   4])

v9 = vector([0,  0, -2,  0,  4, -2, 12,  8, -18])


And we already have a "misplaced" situation, since the parents of the objects are

sage: v1.parent()
Ambient free module of rank 9 over the principal ideal domain Integer Ring


So sage does its best to initialize the structure in the more general setting of the ring of integers $\Bbb Z$. One can also mention the "right ring" when initializing the object, e.g. via

sage: vector(QQ, [1,  0,  2,  2,  0,  4,  4,  0,  10])
(1, 0, 2, 2, 0, 4, 4, 0, 10)
sage: vector([1,  0,  2,  2,  0,  4,  4,  0,  10], QQ)
(1, 0, 2, 2, 0, 4, 4, 0, 10)


This is not so important below, because sage will tacitly coerce. But it is always good to keep in mind to init objects in the right mathematical structure.

Now the particularity of the situation is that the given eight vectors are forming a space of dimension five.

sage: M = matrix(QQ, [v1, v2, v3, v4, v5, v6, v7, v8])
sage: M
[ 1  0  2  2  0  4  4  0 10]
[ 0  1  1  3  3  2  3  2  5]
[ 1  2  4  8  6  8 10  4 20]
[ 1  2  0  4 10  0  6 20  0]
[ 0  1  3  3  5 10  9 10 11]
[ 1  4  6 10 20 20 24 40 22]
[ 1 -1  1 -1 -3  2  1 -2  5]
[ 0  1 -2  1 -2  0  4  0  4]

sage: M.rank()
5


Now the imperative task from the title wants you to do the (home)work and find the relation. Suggesting there is one such relation. Well, there may be many of them. We need first some independent lines. Using slicing, we can get some part of the matrix quickly. So the part of the matrix using the first five (=rank) rows is of full rank?

sage: M[(0,1,2,3,4), :]
[ 1  0  2  2  0  4  4  0 10]
[ 0  1  1  3  3  2  3  2  5]
[ 1  2  4  8  6  8 10  4 20]
[ 1  2  0  4 10  0  6 20  0]
[ 0  1  3  3  5 10  9 10 11]
sage: M[(0,1,2,3,4), :].rank()
4


Nope. We need first some five rows that are independent... There are $\binom 85$ ways to pick a selection of five rows from all eight, we stop already when we find some good rows.

for sel in Combinations(range(8), 5):
if M[sel, :].rank() == 5:
print(sel)
break


And we obtain:

sage: for sel in Combinations(range(8), 5):
....:     if M[sel, :].rank() == 5:
....:         print(sel)
....:         break
....:
[0, 1, 3, 4, 7]
sage: sel
[0, 1, 3, 4, 7]


So the vectors $v_0,v_1,v_3,v_4,v_7$, i.e. v1, v2, v4, v5, v8 are building a linear independent system $S$, and generate a space $V$ of dimension five. Is v9 also in this space? How to write it linearly in terms of $S$?

To answer the above question, let us start again in the right manner. We introduce the space $W=\Bbb Q^9$, where all the given vectors are living in, associate the subspace generated by the given vectors, and ask for a basis, and if v9 is also in there.

W = VectorSpace(QQ, 9)
V = W.subspace([
W([1,  0,  2,  2,  0,  4,  4,  0,  10])
, W([0,  1,  1,  3,  3,  2,  3,  2,   5])
, W([1,  2,  4,  8,  6,  8, 10,  4,  20])
, W([1,  2,  0,  4, 10,  0,  6, 20,   0])
, W([0,  1,  3,  3,  5, 10,  9, 10,  11])
, W([1,  4,  6, 10, 20, 20, 24, 40,  22])
, W([1, -1,  1, -1, -3,  2,  1, -2,   5])
, W([0,  1, -2,  1, -2,  0,  4,  0,   4]) ])

v9 = W([0,  0, -2,  0,  4, -2, 12,  8, -18])

v9 in V


And we obtain the information:

sage: v9 in V
False


Well, in this case... we could also have the decision searching for it in the first approach...

M = matrix(QQ, [v1, v2, v3, v4, v5, v6, v7, v8])
N = matrix(QQ, [v1, v2, v3, v4, v5, v6, v7, v8, v9])


And we ask for the ranks:

sage: M.rank()
5
sage: N.rank()
6


So adding v9 the space gets a higher rank, no chance to linearly write v9 in terms of the other vectors...

This is maybe a good point to rethink your strategy of using computer algebra systems like sage. Always do the job in the mathematical world, then if this world needs the computational support, then ask questions one by one, is the last vector in the right space, how can one test this, if it is there, how to get in the special case a linear combination... You do not provide any information on the problem (source, level, country where it was stated, kind of examination of exercise book...) - this make every answer a (typing) pain. Please always give all you have, all you tried, all your thoughts. This makes answering the question or giving the one-line-hint much much easier.