How to check if m n-sized vectors are linearly independent?

tunnuz picture tunnuz · Feb 10, 2009 · Viewed 44.1k times · Source

Disclaimer
This is not strictly a programming question, but most programmers soon or later have to deal with math (especially algebra), so I think that the answer could turn out to be useful to someone else in the future.

Now the problem
I'm trying to check if m vectors of dimension n are linearly independent. If m == n you can just build a matrix using the vectors and check if the determinant is != 0. But what if m < n?

Any hints?


See also this video lecture.

Answer

David Hanak picture David Hanak · Feb 10, 2009

Construct a matrix of the vectors (one row per vector), and perform a Gaussian elimination on this matrix. If any of the matrix rows cancels out, they are not linearly independent.

The trivial case is when m > n, in this case, they cannot be linearly independent.