Matrices that Commute with of a Specific matrix Let $a$ and $b$ be real numbers. Considere the $2\times 2$ matrix 
\begin{equation*}A=\left[\begin{array}{cc}a&amp;b\\-b&amp;a\end{array}\right].
\end{equation*}
What is the centralizer of the matrix $A$ in $M_2(\mathbb R)$?
If $b=0$, then $A=aI_2$ and we have $AX=XA$ for every $X \in M_2(\mathbb{R})$, i.e. the centralizer of $A=aI_2$ is the whole $M_2(\mathbb{R})$. 

Let us now assume that $b\ne 0$, and let
$$
X=\left[\begin{array}{cc}x_{11}&amp;x_{12}\\x_{21}&amp;x_{21}\end{array}\right] \in M_2(\mathbb{R}).
$$
Then 
\begin{eqnarray}
AX&amp;=&amp;\left[\begin{array}{cc}a&amp;b\\-b&amp;a\end{array}\right]\left[\begin{array}{cc}x_{11}&amp;x_{12}\\x_{21}&amp;x_{22}\end{array}\right]=
\left[\begin{array}{cc}ax_{11}+bx_{21}&amp;ax_{12}+bx_{22}\\-bx_{11}+ax_{21}&amp;-bx_{12}+ax_{22}\end{array}\right]\cr
XA&amp;=&amp;\left[\begin{array}{cc}x_{11}&amp;x_{12}\\x_{21}&amp;x_{22}\end{array}\right]\left[\begin{array}{cc}a&amp;b\\-b&amp;a\end{array}\right]=
\left[\begin{array}{cc}ax_{11}-bx_{12}&amp;bx_{11}+ax_{12}\\ax_{21}-bx_{22}&amp;bx_{21}+ax_{22}\end{array}\right]\cr
\end{eqnarray}
It follows that
$$
AX=XA \iff 
\left\{
\begin{array}{l}
ax_{11}+bx_{21}=ax_{11}-bx_{12}\\
ax_{12}+bx_{22}=bx_{11}+ax_{12}\\
-bx_{11}+ax_{21}=ax_{21}-bx_{22}\\
-bx_{12}+ax_{22}=bx_{21}+ax_{22}
\end{array}
\right.\iff
\left\{
\begin{array}{l}
b(x_{11}-x_{22})=0\\
b(x_{12}+x_{21})=0
\end{array}
\right..
$$
Since $b\ne 0$, we have $x_{22}=x_{11},\ x_{21}=-x_{12}$, i.e. the centralizer of $A$ is formed by matrices of the form
$$
\left[
\begin{array}{cc}
x&amp;y\\
-y&amp;x
\end{array}
\right], \quad x, y \in \mathbb{R}.
$$
Alternatively, if two matrices commute they must have the same eigenvectors if they are simultaneously diagonlizable.  Let $Av = \lambda v$  and $AB = BA$.  Then 

$$  A(Bv)= (BA)(v) =    \lambda (Bv)     $$

Simultaneously diagonzliable matrices are discussed a few times in math.stackexchange:


Matrices commute if and only if they share a common basis of eigenvectors?
How do I prove that in every commuting family there is a common eigenvector?


In any case, since $\det A = a^2 + b^2 \neq 0$ your matrix is a rotation in the plane.  Therefore $B$ must also be a rotation, so 

$$ B  = c \left( \begin{array}{cc}  \cos \theta  &amp;  -\sin \theta \\ \sin \theta  &amp; \cos \theta  \end{array} \right) 
= \left( \begin{array}{cc}  c  &amp;  -d \\ d  &amp; c  \end{array} \right)$$
for some $c, d \in \mathbb{R}$.