while doing this entire fiasco sort of it has to be a full rank matrix if not the matrix has to be modified to only include independent column vectors?
Yes, exactly! This highlights a crucial point about least squares solutions:
For AᵀAx = Aᵀb to have a unique solution, AᵀA must be invertible. This requires that:
If A is rank-deficient (has linearly dependent columns):
In practical terms, when columns are nearly linearly dependent (multicollinearity), even though AᵀA is technically invertible, the solution can be numerically unstable. This is why techniques like QR decomposition are often preferred over directly computing (AᵀA)⁻¹.