Solve $Ax=b$ if $A$ is singular

423 Views Asked by At

I have a matrix:

$$\begin{pmatrix}-1&0&-0.25\\ -2&2&2.5\\ 2&-1&-1\end{pmatrix} \begin{pmatrix}x_1\\ x_2\\ x_3\end{pmatrix} = \begin{pmatrix}-0.25\\ -1.5\\ 1\end{pmatrix}$$

I am trying to solve this problem. How can I do so if A is singular? I tried running it in Python and it has issues.

from scipy.linalg import solve

A=np.array([[-1,0,-0.25], [-2,2,2.5], [2,-1,-1]])
b=np.array([[-0.25,-1.5,1]])
x = solve(A, b.T)

I get LinAlgError: Matrix is singular.