How can I solve this maximization problem with inequality constraint on the Frobenius norm? $$
\max_{C\in \mathbb{S}^n} x^TCx\\
s.t. \|C\|_{tr}^2\leq b
$$
where $\|C\|_{tr}^2=tr(C^TC)=tr(CC)$, $C$ is a symmetric matrix.
 A: Rephrasing slightly, given vector ${\rm a} \in \Bbb R^n \setminus \{ \Bbb 0_n \}$ and scalar $b >0$,
$$\begin{array}{ll} \text{maximize} & {\rm a}^\top {\rm X} \, {\rm a}\\ \text{subject to} & \| {\rm X} \|_{\text{F}} \leq b\end{array}$$
Using the cyclic property of the trace, the Cauchy-Schwarz inequality and $\| {\rm a} {\rm a}^\top \|_{\text{F}} = \| {\rm a} \|_2^2$,
$${\rm a}^\top {\rm X} \, {\rm a} = \mbox{tr} \left( {\rm a}^\top {\rm X} \, {\rm a} \right) = \mbox{tr} \left( {\rm a} {\rm a}^\top {\rm X} \right) = \langle {\rm a} {\rm a}^\top, {\rm X} \rangle \leq \| {\rm a} {\rm a}^\top \|_{\text{F}} \underbrace{\| {\rm X} \|_{\text{F}}}_{\leq b} \leq b \| {\rm a} \|_2^2$$
where the maximum is attained at
$$\bar{{\rm X}} := b \underbrace{\frac{{\rm a} {\rm a}^\top}{\,\,\,\| {\rm a} {\rm a}^\top \|_{\text{F}}}}_{=: {\rm P}_{\rm a}} = b \left( \frac{{\rm a}}{\,\,\,\| {\rm a} \|_2} \right) \left( \frac{{\rm a}}{\,\,\,\| {\rm a} \|_2} \right)^\top = b \, {\rm P}_{\rm a}$$
where ${\rm P}_{\rm a}$ is a rank-$1$ projection matrix.
A: Through some calculations, I have an idea as follows:
$$
L=x^TCx-\lambda(\|C\|_{tr}^2-b)
$$
Calculating $\frac{\partial L}{\partial C}$ and $\frac{\partial L}{\partial \lambda}$, we have
$$
\frac{\partial L}{\partial C}=xx^T=\lambda C\\
\frac{\partial L}{\partial \lambda}=tr(CC^T)=b
$$
that is
$$
C=\frac{xx^T}{\lambda}
$$
plugging the term into the second equation, we have
$$
tr(xx^T/\lambda)=\sqrt{b}\\
tr(xx^T/\lambda)=1=\sum{x_i^2}/\lambda\\
\lambda = \|x\|^2=\sum{x_i^2}
$$
Hence, the solution is
$$
C^*=\sqrt{b}*\frac{xx^T}{\|x\|^2}
$$
