# How to solve system of equations with almost-zero determinant?

I have a system of equations that I am trying to solve. In matrix form, it's written as

$$x(I - S) = b.$$

I am solving for $$x$$, where $$I$$ is the identity matrix and $$S$$ is a matrix where each column sums up to one. $$b$$ is strictly positive.

Now, unfortunately, the determinant of $$I - S$$ is very small. Inverting it leads to a matrix that is huge everywhere, and even numpy.linalg.solve comes up with a solution for $$x$$ that is huge (every element around e+19). What is an alternative way of solving this? The matrix itself is not large, there are around 30-50 elements in $$x$$.

• I don't know, but maybe some regularization method could be useful. – VoB Apr 7 at 13:37
• Usually SVD helps for such situations – Maxim Umansky Apr 8 at 18:24

That matrix is singular, so the system has either zero or infinite solutions. In the case of your system, I think some Perron-Frobenius theory can be used to prove that there are zero: there is a non-negative vector such that $$Sv=v$$, hence $$0=x(I-S)v=bv > 0$$, contradiction. (Those $$x$$ and $$b$$ are row vectors, right?)
• $x$ and $b$ are column vectors – FooBar Apr 7 at 14:39
• Note that you can't multiply a column vector $x$ by $(I-S)$. You could write this as $x^{T}(I-S)=b^{T}$ if $x$ and $b$ are to be column vectors. – Brian Borchers Apr 7 at 15:38
• If you change the question I can edit the answer accordingly. Anyway, the algebra is slightly different, but all claims here still hold if $x,b$ are column vectors: your system has no solution. – Federico Poloni Apr 7 at 17:15