<s>[INST] 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?
 [/INST] 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.
</s>