The self-adjoint operator commute It is an exercise in Hunter's Applied Analysis:
Let A and B self adjoint operators,and let $AB=BA$, $A^2=B^2$. $P$ is the projection operator on the null space $L$ of $A-B$. I want to prove the following three :
1) Any bounded linear operator that commutes with $A-B$ commutes with $P$
2) $Ax=0$ $\implies$ $Px=x$
3) $A=(2P-1)B$
 A: 1) This part of the question holds even without requiring $AB=BA$ or $A^2=B^2$. Let $T$ be a selfadjoint operator that commutes with $A-B$. Write $Q=I-P $; then $$\text {ran}(Q)^\perp=\ker Q=\ker (I-P)=\text {ran}(P)=\ker (A-B)=\text {ran}(A-B)^\perp. $$ For any vector $v$ we have $Qv=(A-B)w$ for some $w$, so
$$
TQv=T(A-B)w=(A-B)Tw.
$$
This implies that $TQ=QTQ$. As we were assuming $T=T^*$, we have $QT=(TQ)^*=(QTQ)^*=QT^*Q=QTQ=TQ$. So $T$ commutes with $P$. If you now consider a general $T$, it is written as a linear combination of selfadjoints (i.e. real and imaginary parts), and the result follows. 
2) If $Ax=0$, then $B^2x=A^2x=0$. As $B $ is selfadjoint, $Bx=0$. Then $(A-B)x=0$ and so $Px=x $.
3) Since $AB=BA$, the operators $A$ and $B$ can be simultaneously diagonalized, i.e. there exist spectral measure $E$ and Borel functions $f,g$, which are zero off the support of $E$, such that
$$
A=\int\,f\,dE,\ \ B=\int\,g\,dE.
$$
From $A^2=B^2$ we get that $f^2=g^2$. Then there exists measurable $h$, taking values in $\{-1,1\}$, such that $g=hf$. So
$
A-B=\int\,(1-h)f,
$
and $P=E\{h=1\}$. So
$$
2P-I=2\int_{h=1}\,1\,dE-\int\,1\,dE=\int_{h=1}1\,dE-\int_{h=-1}\,1\,dE=\int h\,dE.
$$
So, noting that $h=h^{-1}$,
$$
(2P-I)B=\int hg\,dE=\int\,f\,dE=A.
$$
