2
$\begingroup$

In MATLAB/Python, is there a way to compare the subspaces span by two different sets of vectors and check if they are the same?

$\endgroup$
4
$\begingroup$

Utilizing the fact that $A$ and $rref(A)$ has the same row space, check if the two matrices (with the given vectors as row vectors) have the same Reduced Row Echelon Form.

$\endgroup$
2
$\begingroup$

Corrected version following a remark of @Quang Hoang

Here is another way :

If the sets of vectors are the columns of $A$ and $B$ resp., check that the new matrix $C=[A,B]$ is such that

$$rank(A)=rank(B)=rank(C)$$

Proof: Let $R(M)$ denote the column space of a matrix $M$.

Equality $rank(A)=rank(C)$ implies $R(A)=R(C)$ Equality $rank(B)=rank(C)$, implies $R(B)=R(C)$. Thus $R(A)=R(B)$. Therefore $rank(A)=rank(B)$.

$\endgroup$
  • $\begingroup$ This is actually a very clever yet simple move! Don't know if it works for all cases though. $\endgroup$ – Quang Thinh Ha May 18 '16 at 10:42
  • $\begingroup$ Why do you think there are cases where it doesn't work ? The only problem that might impair the method (but that would impair all methods) is the use of approximations (in particular in large dimensions). $\endgroup$ – Jean Marie May 18 '16 at 11:17
  • $\begingroup$ The numerical errors is the main reasons why, but I guess I am a hypocrite worrying about numerical errors while using MATLAB/Python... $\endgroup$ – Quang Thinh Ha May 18 '16 at 11:22
  • $\begingroup$ This is not true, it only guarantees that the column space of $B$ is contained in that of $A$. You need to check that $rank(C)=rank(B)=rank(A)$. $\endgroup$ – Quang Hoang May 18 '16 at 15:38
  • $\begingroup$ @Quang Hoang You are perfectly right. I correct immediately my answer. $\endgroup$ – Jean Marie May 18 '16 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.