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

前端 未结 8 2450
栀梦
栀梦 2020-12-15 05:47

Disclaimer
This is not strictly a programming question, but most programmers soon or later have to deal with math (especially algebra), so I think tha

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 06:15

    A very simple way, that is not the most computationally efficient, is to simply remove random rows until m=n and then apply the determinant trick.

    • m < n: remove rows (make the vectors shorter) until the matrix is square, and then
    • m = n: check if the determinant is 0 (as you said)
    • m < n (the number of vectors is greater than their length): they are linearly dependent (always).

    The reason, in short, is that any solution to the system of m x n equations is also a solution to the n x n system of equations (you're trying to solve Av=0). For a better explanation, see Wikipedia, which explains it better than I can.

提交回复
热议问题