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?
2025-01-13 05:28:50.1736746130
How to check if two sets of vectors span the same space in matlab/python?
7.1k Views Asked by Quang Thinh Ha https://math.techqa.club/user/quang-thinh-ha/detail At
2
There are 2 best solutions below
5
On
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)$.
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.