State-space to transfer function I’m looking into MATLAB’s state-space functionality, and I found a peculiar relation that I don’t believe I’ve seen before, and I’m curious how one might obtain it. According to this documentation page, when converting a state-space system representation to its transfer function, the following well-known equality is used
$$H(s) = C(sI-A)^{-1}B$$
However, they go one step further and state that
$$H(s) = C(sI-A)^{-1}B = \frac{{\det}(sI-A+BC) - {\det}(sI-A)}{\det(sI-A)}$$
How did they manage to convert $C{\text {Adj}}(sI-A)B$ into ${\det}(sI-A+BC) - {\det}(sI-A)$?
As far as I understand, we can assume here that $B$ is a column vector and $C$ is a row vector, i.e. it’s a single-input / single-output relationship.

They are using the Sherman-Morrison formula, which I remember best in the form
$$
 \det(I+MN) = \det(I+NM);
$$
this holds provided that both products $MN$ and $NM$ are defined. Note that if $M$ is
a column vector and $N$ a row vector, then $I+NM$ is a scalar. Now
$$\begin{align}
 \det(sI-A+BC) &= \det\left((sI-A)(I+(sI-A)^{-1}BC\right)\\ &= \det(sI-A)\det(I+(sI-A)^{-1}BC) \tag{1}.
\end{align}
$$
Applying the formula with $M=I+(sI-A)^{-1}B$ and $N=C$ yields that
$$
 \det(I+(sI-A)^{-1}BC) = \det(I+C(sI-A)^{-1}B).
$$
If $B$ is a column vector and $C$ a row vector then the final determinant is equal to
$$
 1 + C(sI-A)^{-1}B \tag{2}
$$
Plugging (2) to (1), gives 
$$
\det(sI-A+BC) = \det(sI-A)\left( 1 + C(sI-A)^{-1}B \right)
$$
Shuffling terms gives the result.
