Formula for determinant of block matrix with commuting blocks
On Wikipedia, I saw the following formula
$$\det\begin{bmatrix}A & B\\ C & D\end{bmatrix} = \det(AD-BC)$$
if $C$ and $D$ commute. Is this always true?
Or is there a good counter example for each $2 \times 2$ block matrices?
Yes, it's always true, but note that there is a premise to fulfill: $C$ and $D$ have to commute, that is, we need $CD=DC$. If this condition is violated, the formula may fail to hold.
More generally, when the entries of $A,B,C,D$ be matices over a commutative ring (this includes, but isn't limited to, the cases where $A,B,C,D$ are real or complex matrices), we have $$ \det \pmatrix{A&B\\ C&D}= \begin{cases} \det(AD-BC) & \text{ if } CD=DC,\\ \det(DA-CB) & \text{ if } AB=BA,\\ \det(DA-BC) & \text{ if } BD=DB,\\ \det(AD-CB) & \text{ if } AC=CA. \end{cases} $$ This was first proved by M. H. Ingraham (see his paper A note on determinants) and later proved independently by John Silvester (see his paper). Essentially, suppose $AC=CA$ (this is the last case in the above). Then $$ \pmatrix{I&0\\ -C&A+xI}\pmatrix{A+xI&B\\ C&D}=\pmatrix{A+xI&B\\ AC-CA&(A+xI)D-CB}. $$ By assumption, $AC-CA=0$, so the RHS is block-triangular and $$\det(A+xI)\,\det\pmatrix{A+xI&B\\ C&D}=\det(A+xI)\,\det\left((A+xI)D-CB\right).$$ As $\det(A+xI)$ is a nonzero polynomial in $x$, we can divide both sides by it and obtain $\det\pmatrix{A+xI&B\\ C&D}=\det\left((A+xI)D-CB\right)$. Put $x=0$, the assertion follows. The proofs for the other three cases are similar.
Remark. Those who are familiar with Schur complement may recognise that the same technique using block matrix decomposition is also used in the derivation of Schur complement. In fact, if the matrix entries are taken from a field, we can use Schur complement to prove the above formula. E.g. suppose again that $AC=CA$. Let $x$ be an indeterminate and extend the underlying field $F$ to $F(x)$, the field containing all rational functions in $x$. Then $A+xI$ is invertible and it commutes with $C$. Therefore, by using Schur complement, we get \begin{aligned} \det\pmatrix{A+xI&B\\ C&D} &=\det(A+xI)\det\left(D-C(A+xI)^{-1}B\right)\\ &=\det(A+xI)\det\left(D-(A+xI)^{-1}CB\right)\\ &=\det\left((A+xI)D-CB\right) \end{aligned} and the assertion again follows by putting $x=0$.