My question is the following:

Suppose $M$ is an $n \times n$ symmetric real matrix. I want to find an $n \times n$ symmetric real matrix X such that $|| X -M||_F$ is minimized with the constraint that $U^T X U \succeq 0$ (positive semidefinite), where $U$ is an $n \times d$ matrix, $U^TU = I_d$ and $n > d$. $|| \cdot ||_F$ is the Frobenius norm of matrix. In short: \begin{equation} X^* = \displaystyle \operatorname{argmin}_{X:U^TXU\succeq 0}||X-M ||_F, X, M \in \mathcal{S_n} \end{equation}

Some useful information may be: $U$ can be obtained from eigenvalue decomposition of $BB^T$ or QR decomposition of $B$ in the sense that there exists $Q = [U,V]$ such that $Q^TQ = QQ^T = I_n, U^TB = 0$.

I would like to find a formula or construction based on eigenvalue decomposition or singular value decomposition for M. For example, if the constraint is $X \succeq 0$ instead of $U^T X U \succeq 0$, we can first apply eigenvalue decomposition to $M$ such that $M = Q \operatorname{diag}(\lambda_1,\cdots, \lambda_n) Q^T$, then $X^* =Q \operatorname{diag}(\max\{\lambda_1,0\},\cdots, \max\{\lambda_n,0\}) Q^T $ would minimize $|| X-M ||_F$.

I used CVX package to compute $X^*$ for some examples and I found some interesting facts: $ (X^*-M) B = 0$ where $U^TB=0$ and $X^* -M$ is always positive semidefinite while $M$ and $X^*$ may not be positive semidefinite. Any help or suggestion of what method or tools I should use for these kind of problems would be much appreciated! Thanks~