According to the theory I've read, if $A$ is singular, the equation $A\vec{x}=\vec{b}$ will have either zero or infinitely many solutions. I tried solving this equation for: $$A=\begin{bmatrix} 4 & 4 & 3 \\ -4 & -4 & -3 \\ 3 & 3 & 3 \end{bmatrix}, b=\begin{bmatrix} -1 \\ 1 \\ 0 \end{bmatrix} $$ Solving by hand gives $x=[-1, 1, 0] * x_2 + [-1, 0, 1]$. So one solution for $x_2 = 0$ would be $[-1, 0, 1]$ which works.
When I try to solve it using WolframAlpha, here, it says no solutions exists. When I try to solve it in python using np.linalg.solve, I get LinAlgError: Singular matrix.
How can I solve this type of equation for singular matrices using python or WolframAlpha? How come several computer programs how problems with this kind of equation?
For symbolic computation the easiest way is to use rref:
And in Wolfram Alpha like this:
rref{{4,4,3,-1},{-4,-4,-3,1},{3,3,3,0}}Taking the LU decomposition only gets you halfway there, and it is easier to use rref in my opinion.
For numerical (floating point), which is what numpy uses, the two other answers gives the best way. This is because floating point calculations doesn't give exact answers, so some way to get an approximation is needed. This is done with different variants of the least-squares method.
Here is a discussion about why numpy does not include rref.