# Generating random vectors list which are linearly independent

How can I get n(maybe 10) vectors that are linearly independent from a vector space?

gen=VectorSpace(GF(29),9)
basis=[gen.random_element() for i in range(10)]
print(gen.linear_dependence(basis)==[]) #False

edit retag close merge delete

1

You cannot get 10 linearly independent vectors in a 9-dimensional vector space.

( 2022-01-29 00:51:22 +0200 )edit

Sort by ยป oldest newest most voted

You can get up to 9 linearly independent vectors from a 9-dimensional space. This gives 9 vectors over GF(29), if you need less - just pick a subset of them:

Matrix( SL(9, GF(29)).random_element() ).rows()

more

Another approach, maybe more along the lines you were thinking:

sage: gen=VectorSpace(GF(29),9)
sage: basis = []
sage: while len(basis) < gen.dimension():
....:     v = gen.random_element()
....:     if not gen.linear_dependence(basis + [v]):
....:         basis.append(v)
....:

more

thank you for all answers,I totally understand

more