0

I have a list of vectors in the vector space Q with a dimension of 5, which I want to order in a list and use Combinations(list, 4) to get all sublists with 4 elements. I then want to check how many of those sublists are linear independent in the Vector Space with V.linear dependence(vs) == [].

I'm running into an error when running my code:

V = VectorSpace(QQ,5) V.list = ([2, 2, 2,-3,-3],[2, 2,-3,2,-3],[2,2,-3,-3,2],[2,-3,2,2,-3],[2,-3,2,-3,2],[2,-3,-3,2,2],[-3,2,2,2,-3],[-3,2,2,-3,2],[-3,2,-3,2,2],[-3,-3,2,2,2]) C = Combinations(list, 4) V.linear_dependence(C) == []

"ValueError: vector [[2, 2, 2, -3, -3], [2, 2, -3, 2, -3], [2, 2, -3, -3, 2], [2, -3, 2, 2, -3]] is not an element of Vector space of dimension 5 over Rational Field"

Anyone got any clues as to what im missing?

  • Also posted at https://ask.sagemath.org/question/44543/number-of-linear-independent-subsets-with-cardinality-4/ – kcrisman Dec 07 '18 at 18:40

1 Answers1

0

You are asking it to just take a list (or actually, tuple) and put it in the vector space, but I think Sage doesn't do that automatically. Try this.

V = VectorSpace(QQ,5)
list = ([2, 2, 2,-3,-3],[2, 2,-3,2,-3],[2,2,-3,-3,2],[2,-3,2,2,-3],[2,-3,2,-3,2],[2,-3,-3,2,2],[-3,2,2,2,-3],[-3,2,2,-3,2],[-3,2,-3,2,2],[-3,-3,2,2,2])
C = Combinations(list, 4)
for c in C:                                                               
    if V.linear_dependence([V(x) for x in c]) == []: print c 

The reason for a double list is that neither of these things are inherently in a vector space.

A slight modification to this, replacing print c with z+=1 (having predefined z=0) says that 185 of your 210 combinations appear to be linearly independent.

By the way, comparing to the empty list might not be as efficient as other options.

kcrisman
  • 4,374
  • 20
  • 41