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)$ ?