Commuting real matrices 
Given three real $n\times n$ matrices $X,Y,Z$ satisfying the following conditions:
$$XZ=ZX$$
$$YZ=ZY$$
$$\mathrm{rank}(XY-YX+I)=1,$$
prove that $Z=aI$ for some real number $a$.

One possible solution to this problem has been sketched in the comments years ago. The idea is that, up to conjugation by a complex invertible matrix, we can assume $Z$ to be a Jordan matrix. This forces the matrices $X,Y$ to have a precise block structure and the remaining part of the proof should be achieved after some rather long computation.
I would like to know if the problem can be solved in an easier/faster way.
 A: here's a partial proof that addresses algebraic multiplicities of eigenvalues
all matrices are n x n unless indicated otherwise
Leg one:  Z has a single eigenvalue $\sigma$ with algebraic multiplicity $n$.
$\mathrm{rank}(XY-YX+I)=1\longrightarrow XY-YX+I = \mathbf a\mathbf b^T$
taking the trace of each side, we see
$\text{trace}\big(XY\big)-\text{trace}\big(YX\big)+\text{trace}\big(I_n\big) =  n = \text{trace}\big(\mathbf a\mathbf b^T\big)$
Thus $\mathbf {ab}^T$ is rank one with trace $n$ so it may be diagonalized by some matrix $S$.
where $\mathbf e_k$ denotes the kth standard basis vector, we have
$S^{-1}\big(XY-YX+I\big)S = (S^{-1}XS)(S^{-1}YS)-(S^{-1}YS)(S^{-1}XS)+I = S^{-1}\mathbf a\mathbf b^TS = n \mathbf e_1\mathbf e_1^T$
at this point, we could formally do a change of variables and define
$X':=(S^{-1}XS)$, $Y':=(S^{-1}YS)$, $Z':=(S^{-1}ZS)$
conjugation doesn't change commuting but for notational simplicity we instead proceed by assuming WLOG that
$XY-YX =n \mathbf e_1\mathbf e_1^T- I$
since $Z$ commutes with the $LHS$ it commutes with the $RHS$, and
$Z\big(n \mathbf e_1\mathbf e_1^T- I\big) = \big(n \mathbf e_1\mathbf e_1^T- I\big)Z\longrightarrow Z=  \left[\begin{matrix}\sigma &\mathbf 0^T\\\mathbf 0 &Z_{n-1}\end{matrix}\right]$
from here
$Z'' := Z -\sigma I$
(which preserves commuting with $X$ and $Y$)
$(Z'')^k\big(XY-YX\big)= \left[\begin{matrix}0 &\mathbf 0^T\\\mathbf 0 &(Z_{n-1}-\sigma I_{n-1})^k\end{matrix}\right]\left[\begin{matrix}n-1 &\mathbf 0^T\\\mathbf 0 &-I_{n-1}\end{matrix}\right]  =  \left[\begin{matrix}0 &\mathbf 0^T\\\mathbf 0 &-(Z_{n-1}-\sigma I_{n-1})^k\end{matrix}\right]$
taking the trace of each side, we have
$-\text{trace}\Big((Z_{n-1}-\sigma I_{n-1})^k\Big) $
$= \text{trace}\Big((Z'')^k\big(XY-YX\big)\Big) $
$= \text{trace}\Big((Z'')^kXY\Big)-\text{trace}\Big((Z'')^kYX\Big) $
$= \text{trace}\Big((Z'')^kXY\Big)-\text{trace}\Big(X(Z'')^kY\Big) $
$= \text{trace}\Big((Z'')^kXY\Big)-\text{trace}\Big((Z'')^k XY\Big) $
$=0$
thus $(Z_{n-1}-\sigma I_{n-1})$ is nilpotent.  I.e. $Z$ has eigenvalue $\sigma$ with algebraic multiplicity $n$
A: Here is a solution that uses Jordan normal form. First, note that $XY-YX+I$ cannot be rank-one when, via the same similarity transform,
$$
X\sim\pmatrix{U_1&U_2\\ 0&U_3},\ Y\sim\pmatrix{V_1&V_2\\ 0&V_3}\tag{1}
$$
where $U_1,V_1$ are $r\times r$ for some $0<r<n$ and $U_3,V_3$ are $(n-r)\times(n-r)$. This is because $(1)$ implies that
$$
XY-YX+I\sim\pmatrix{U_1V_1-V_1U_1+I_r&\ast\\ 0&U_3V_3-V_3U_3+I_{n-r}},
$$
but the ranks of both $U_1V_1-V_1U_1+I_r$ and $U_3V_3-V_3U_3 +I_{n-r}$ are at least $1$ (because the two matrices have nonzero traces), so that
$$
\operatorname{rank}(XY-YX+I_n)\ge\operatorname{rank}(U_1V_1-V_1U_1+I_r)+\operatorname{rank}(U_3V_3-V_3U_3 +I_{n-r})\ge2.
$$
Now, if $Z$ has $k>1$ different eigenvalues $\lambda_1,\lambda_2,\ldots,\lambda_k$, by a change of basis over $\mathbb C$, we may assume that $Z$ is in Jordan form $Z=Z_1\oplus\cdots\oplus Z_k$, where each submatrix $Z_i$ is a Jordan form for the eigenvalue $\lambda_i$. Since $X$ and $Y$ commute with $Z$, they must assume block-diagonal forms $X=X_1\oplus\cdots\oplus X_k$ and $Y=Y_1\oplus\cdots\oplus Y_k$ where both $X_i$ and $Y_i$ have the same sizes as $Z_i$. But then $X$ and $Y$ will be in the form of $(1)$, which is a contradiction to the assumption that $\operatorname{rank}(XY-YX+I_n)$ has rank $1$.
Therefore $Z$ must possess a single eigenvalue $\lambda$ of multiplicity $n$. We may assume that $Z=J_{r_1}\oplus\cdots\oplus J_{r_m}$, where each $J_{r_i}$ denotes a Jordan block of size $r_i$ for the eigenvalue $\lambda$, with $1\le r_1\le\cdots\le r_m$ and $r_1+\cdots+r_m=n$.
Every matrix $B$ that commutes with such a Jordan form $Z$ can be partitioned into a block matrix form $(B_{ij})$, where each sub-block $B_{ij}$ is of the form
$$
\mathbb R^{r_i\times r_j}\ni
B_{ij}=
\begin{cases}
T_{ij}&\text{if }r_i=r_j\\
\pmatrix{T_{ij}\\ 0}&\text{if }r_i>r_j\\
\pmatrix{0&T_{ij}}&\text{if }r_i<r_j\\
\end{cases}\tag{2}
$$
and $T_{ij}\in\mathbb R^{\min(r_i,r_j)\times\min(r_i,r_j)}$ is an upper triangular (square) Toeplitz matrix. Since each $B_{ij}$ is "upper triangular", if we put $\mathcal I=\{1,\,1+r_1,\,1+r_1+r_2,\,\ldots,\,1+r_1+r_2+\cdots+r_{m-1}\}$ (i.e. each element of $\mathcal I$ is the row/column index of the top-left element of some sub-block $B_{ij}$ in $B$) and $\mathcal J$ be the complement of $\mathcal I$ in $\{1,2,\ldots,n\}$, then by $(2)$, $B([\mathcal I,\mathcal J],[\mathcal I,\mathcal J])$ will be in the form of $\pmatrix{W_1&W_2\\ 0&W_3}$, where $W_1$ is $m\times m$. Now, if $Z$ has any non-trivial Jordan block, then $m<n$ and hence both $W_1$ and $W_3$ are non-empty. This is true in particular for $X$ and $Y$. But then $(1)$ is true and we arrive at a contradiction. Hence $Z$ cannot have any non-trivial Jordan block, i.e. $Z$ must be a scalar matrix.
A: $XY=YX$ implies $XY-YX=0$ we deduce $XY-YX+I=I$ so $X,Y,Z$ are one dimensional matrices since the rank of $I$ is $1$ and $Z=aI$.
