# Designing a loop that fetches 5 random vectors each with 5 components from a set of 10 until Linear dependence is found

I am currently trying to find a way to make a loop that will select 5 random columns without replacement of a 5x10 matrix until it finds a determinant equal to 0 out of the new matrix formed by the 5 random selections. The 5x10 matrix comes from multiplying the matrix representation of the dihedral group, $D_{10}$ by random (for now) vectors in $R^5$. I then need the loop to create a new vector from $R^5$ and repeat until a vector is found such that the determinant $\neq$ 0. I have written the code that can perform all of these calculations individually, but am trully struggling with the automation of this process via a loop since I am really new to Mathematica. Any help is greatly appreciated!

I'm not exactly sure how to format the code I have up for a post but here is what I've done so far...

\[CapitalGamma] = {{{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0,
0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}, {{0, 0, 0, 0, 1}, {1, 0,
0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1,
0}}, {{0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}, {1, 0, 0, 0, 0}, {0, 1,
0, 0, 0}, {0, 0, 1, 0, 0}}, {{0, 0, 1, 0, 0}, {0, 0, 0, 1,
0}, {0, 0, 0, 0, 1}, {1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}}, {{0, 1,
0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}, {1,
0, 0, 0, 0}}, {{1, 0, 0, 0, 0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1,
0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}}, {{0, 0, 0, 0, 1}, {0, 0,
0, 1, 0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}, {1, 0, 0, 0,
0}}, {{0, 0, 0, 1, 0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}, {1, 0,
0, 0, 0}, {0, 0, 0, 0, 1}}, {{0, 0, 1, 0, 0}, {0, 1, 0, 0,
0}, {1, 0, 0, 0, 0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1, 0}}, {{0, 1,
0, 0, 0}, {1, 0, 0, 0, 0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1, 0}, {0,
0, 1, 0, 0}}};
v = {1, 2, 3, 4, 5};
\[CapitalRho] = Permutations[v];
ovld = \[CapitalGamma].v;
Tovld = Transpose[\[CapitalGamma].v];
l = RandomSample[ovld, 5];
lt = Transpose[l];
lrr = RowReduce[l];
d = Det[l]

• Show what you've gotten so far, that is what's your code. Commented Jun 4, 2015 at 22:19
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Commented Jun 4, 2015 at 22:22
• So I defined $\Gamma$ to be the $D_{10}$ matrix representation, $\mathbf P$ to be the set of permutations of 5 elements of $R^5$ without replacement, and $v$ to be the first item in $\mathbf P$. I then set i = RandomSample[$\Gamma*v$, 5] and am using RowReduce[i] to visually check for dependence. I need each iteration to subtract $\Gamma*v$ from $\mathbf P$ so that once the loop starts again, I'm getting a unique 5x10 matrix from which to work on. I'll do away with RowReduce[i] and set the loop to stop when Determinant[i]=0. Commented Jun 4, 2015 at 22:36
• I feel like since the procedure involves set and matrix operations, this loop isn't as simple as I'd like it to be for a beginner. Commented Jun 4, 2015 at 22:43
• Terrence, it would be most useful if you could add the code, rather than a description thereof, to your original question. You can edit your question at any time (use the "edit" link under the question itself). Commented Jun 5, 2015 at 9:13

This should give some ideas. I add a safety valve in case the rank is always 5.

indx = 0;
det = 1;
While[det != 0 && indx < 100,
indx++;
l = RandomSample[ovld, 5];
det = Det[l];]
{indx, l}

(* Out[163]= {3, {{5, 4, 3, 2, 1}, {4, 3, 2, 1, 5},
{2, 1, 5, 4, 3}, {1, 2, 3, 4, 5}, {2, 3, 4, 5, 1}}} *)

• This is fantastic, than you. I guess I had enough there. Thanks you. Commented Jun 6, 2015 at 16:39
• Is there any way to be sure that "RandomeSample" doesn't repeat the the same collection of 5 vectors here? Commented Jun 11, 2015 at 22:03
• Not easily in general, but for this case not so hard. You could take the set of all Binomial[10,5] subsets and suffle them e.g. with RandomChoice. Then just iterate over the result until you find one you like. Commented Jun 11, 2015 at 22:45