6
Given a set of vectors all of the same positive finite dimension, output a falsey value if they are linearly dependent and a truthy value if they are linearly independent. A set of vectors v1, v2, ... is linearly dependent if for some scalars a1, a2, ... not all equal to 0, a1v1 + a2v2 + ... = 0. (0 is the zero vector.)
Note: Using an inbuilt function to find the rank of a matrix or test vectors for linear dependence is not allowed.
Note 2: All input will be formed from integers.
Test cases (input -> output):
[[0,1],[2,3]] -> True
[[1,2],[2,4]] -> False
[[2,6,8],[3,9,12]] -> False
[[1,2],[2,3],[3,4]] -> False
[[1,0,0],[0,1,0],[0,0,1]] -> True
[[0]] -> False
[] -> True
[[1,1],[0,1],[1,0]] -> False
[[1,2,3],[1,3,5],[0,0,0]] -> False
1Can we take the set of vectors as a rectangular matrix? – Alex A. – 2016-04-19T22:52:36.577
Yes, you can take the input as a rectangular matrix. – poi830 – 2016-04-19T22:53:20.130
Can I take the number of rows and columns as additional input? – El'endia Starman – 2016-04-19T23:07:16.543
2May we call a determinant built-in? – xnor – 2016-04-19T23:10:21.620
5May we try to invert the matrix with a built-in and see if that succeeds? May we call a built-in to find all the eigenvalues? – xnor – 2016-04-19T23:11:51.097
9
@poi830 That seems really ad-hoc. To write a solution that uses linear-algebra functions, it seems like I'd have to guess what you'd allow or not. That strikes me as a mild case of Do X without Y. I understand you don't want cheap solutions with built-ins that just do the problem, but it's a hard line to draw. In particular, many matrix norms and decompositions can indirectly tell you if a set of vectors are independent, even though that's not their purpose.
– xnor – 2016-04-19T23:21:10.613@xnor You could not have said it better – Luis Mendo – 2016-04-19T23:23:57.197
1Edited, determinants and inversions of the matrix are now allowed, but may not be helpful because the matrix is not always square. – poi830 – 2016-04-19T23:25:33.097