Determine all real numbers $x$ for which there exists $3 \times 3$ real matrices $A$ and $B$ such that
$$AB-BA = \begin{pmatrix} 1 & 0 &0 \\ 0 & x& 0\\ 0&0& -1 \end{pmatrix}$$
Determine all real numbers $x$ for which there exists $3 \times 3$ real matrices $A$ and $B$ such that
$$AB-BA = \begin{pmatrix} 1 & 0 &0 \\ 0 & x& 0\\ 0&0& -1 \end{pmatrix}$$
Since $tr(AB) = tr(BA)$, you see that $tr(AB-BA) = 0$. So, the trace of the rhs must also be zero, i.e. $x = 0$.
We have proven so far that, if the equality holds, we must have $x=0$. To complete the proof we must check that when $x=0$, it is possible to find such matrices. We can take for instance $$ A=\left( \begin{array}{ccc} 0 & 0 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ \end{array} \right), \quad B = \left( \begin{array}{ccc} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 1 & 0 & 0 \\ \end{array} \right). $$
Using this fact, we have $$\begin{align}\text{tr}(AB - BA) &= \text{tr}(AB) - \text{tr}(BA)\\ &= \text{tr}(AB) - \text{tr}(AB) \\&= 0 \end{align}$$ But $$\text{tr}\begin{pmatrix} 1 & 0 &0 \\ 0 & x& 0\\ 0&0& -1 \end{pmatrix} = 1+x-1 = x $$ Hence, $x = 0$