TITLE: Let $A=(a_{ij})$ be an $n\times n$ matrix. Suppose that $A^2$ is diagonal. Must $A$ be diagonal?
QUESTION [27 upvotes]: Let $A=(a_{ij})$ be an $n\times n$ matrix. Suppose that $A^2$ is diagonal? Must $A$ be diagonal. 
In other words, is it true that 
$$A^{2}\;\text{is diagonal}\;\Longrightarrow a_{ij}=0,\;i\neq j\;\;?$$

REPLY [30 votes]: As a simplified case, consider $n=2$ and let $$A=\begin{pmatrix}a&b\\c&d\end{pmatrix}\implies A^2=\begin{pmatrix}a^2+bc&b(a+d)\\c(a+d)&d^2+bc\end{pmatrix}$$
so $$A^2\,\,\text{diagonal}\iff b(a+d)=c(a+d)=0\implies\left\{\begin{matrix}
b=c=0 \implies A\,\,\text{diagonal}\\
a+d=0\implies a=-d
\end{matrix}\right.$$
Hence a counterexample would be any matrix of the form $$A=\begin{pmatrix}-d&b\\c&d\end{pmatrix}$$ with $b \ne 0$ or $c \ne 0$ or both.