# Matrix-vector multiplication before evaluating the matrix inverse

Suppose I need to evaluate the expression $$\begin{bmatrix} 0 & 1 & 0 & 0 \end{bmatrix} \begin{bmatrix} s+2 & -1 & 0 & 0\\ 0 & s+3 & 0 & 0\\ -1 & -2 & s & -1\\ 2 & -1 & 1 & 4 \end{bmatrix}^{-1} \begin{bmatrix} 0\\ 1\\ 1\\ 1 \end{bmatrix}$$ If I compute the inverse of the $4 \times 4$ matrix first, then perform the matrix-vector multiplication, I'm left with the result $$\displaystyle \frac{1}{s+3}$$ If instead I perform the matrix-vector multiplication first, keeping in mind that I need to compute the inverse of whatever I'm left with, I get $$(s+3)^{-1} = \displaystyle \frac{1}{s+3}$$

My question is this: is it safe to assume that I can always perform the matrix-vector multiplication first and then compute the inverse of the resulting scalar (assuming, of course, that the result is invertible) or did I just happen to get lucky in this case?

-
This was very much a coincidence. You absolutely cannot rely on that. As the simplest case consider 1x1 matrices. If this "rule" held, we would have the identity $$(a)(b)^{-1}(c)=(abc)^{-1}$$ for all number $a,b,c$. But the lhs is $ac/b$ and the rhs is $1/abc$, so the identity holds only, when $ac=1$. – Jyrki Lahtonen Mar 12 '12 at 7:58
This will only work if $AB^{-1} = (AB)^{-1} = B^{-1}A^{-1}.$ For example if $A^{-1}$ is similar to $A$. – user2468 Mar 12 '12 at 15:56

The value of $$\begin{bmatrix} s+2 & -1 & 0 & 0\\ 0 & s+3 & 0 & 0\\ -1 & -2 & s & -1\\ 2 & -1 & 1 & 4 \end{bmatrix}^{-1}$$ $$\text{is}$$ $$\begin{bmatrix} \frac{1}{s + 2} & \frac{1}{s^2 + 5 s + 6} & 0 & 0 \\ 0 & \frac{1}{s + 3} & 0 & 0\\ \frac{2}{4 s^2 + 9 s + 2} & \frac{9 s + 20}{4 s^3 + 21 s^2 + 29 s + 6} & \frac{4}{4 s + 1} & \frac{1}{4 s + 1}\\ -\frac{2 s + 1}{4 s^2 + 9 s + 2} & -\frac{ - s^2 + 2 s + 5}{4 s^3 + 21 s^2 + 29 s + 6} & -\frac{1}{4 s + 1} & \frac{s}{4 s + 1} \end{bmatrix}$$ Multiplying with the row vector retains the 2nd row and eliminates all others.

$$\begin{bmatrix} 0 & \frac{1}{s + 3} & 0 & 0\\ \end{bmatrix}$$

Multiplying with the column vector picks up the last 3 columns and eliminates others

Answer = $\dfrac{1}{s+3}$

This is, however, merely a coincidence. This is not true in general.

-
+1 But on second thought it is not completely a coincidence. Look at the two top rows of your matrix inverse. The all zeros 2x2 block stays, and the invers of the "upper triangular" 2x2 block in the top left has reciprocals of the original diagonal entries at their places. Also the two vectors conspire to make it happen. But for these two vectors and a matrix of this precise block structure, the same thing does always happen :-) – Jyrki Lahtonen Mar 12 '12 at 20:48
@JyrkiLahtonen, I made a similar observation. Put if we perturb the matrix a little (Make that $2\times2$ block full dense), Then that nice structure might be lost. From the tone of the question, he seemed to be asking in general. I'm not sure but his application seems to be some form of graphics application but I can't be sure. – Inquest Mar 13 '12 at 4:45
It's actually the state space representation of a linear system. I did find one error in my A-matrix (4x4), though it doesn't change the result that the inverse must be computed first. (The (4,4) entry should read s+4) – andykee Mar 17 '12 at 3:23