Consider a real symmetric matrix $A \in\mathbb{R}^{n\times n}$ and the following function
$$ f(A) = 2\cdot\text{tr}(A^\top A) - \Big(\text{tr}(A)\Big)^2 $$
To minimize $f(A)$ we can differentiate and set the derivative to zero. Which implies that $A^* = \frac{1}{2}\text{tr}(\text{A}^*)\mathbb{I}$. The optimal solution suggests that the matrix $A^*$ must be diagonal. However, what if diagonal matrices were not allowed ? Can we find a non-diagonal $A$ that minimizes $f(A)$ ?
No. Let $\langle A, B \rangle = \operatorname{tr} (A^TB)$. This is an inner product.
Let $\phi(A) = 2 \operatorname{tr}(A^TA) - (\operatorname{tr}(A))^2 = 2\langle A, A \rangle - ( \langle I , A \rangle )^2$.
Then $D\phi(A)(H) = 4 \langle A, H \rangle -2 \langle I, A \rangle\langle I, H \rangle = 2 \langle 2A - \langle I, A \rangle I , H \rangle$ and if we set the derivative to zero we get $2A = \langle I, A \rangle I$ or $A = ({1 \over 2} \operatorname{tr} A ) I$.