# How can I project a matrix on the set of symmetric positive definite matrices with trace 1?

Given a square matrix $$A \in \mathbb{R}^{n \times n}$$, I need to compute $$\min_{X \in \Omega} \lVert A - X\rVert^2$$ where $$\Omega = \{X \in \mathbb{R}^{n \times n} |\, {\rm tr}(X) = 1, X \text{ is symmetric, }X \geq 0 \}$$, namely I want the projection of a given matrix on the set $$\Omega$$.

But I also neec to compute it fast. I tried using cvx_solver but it's way too slow computing it directly. is there a better way to write this problem? Or is there a known closed formula or quick algorithm for finding such projection?

• Which norm are you using? Commented Apr 14, 2015 at 1:20
• For the solver I tried using norm 2 and Frobenius norm. But both take a bit long Commented Apr 14, 2015 at 12:42

Using Lagrange multipliers for the conditions $$X-X^T=0$$ and $${\rm tr}(X)=1$$ and for the objective function the Frobenius norm, you get the Lagrange functional $$L(X,U,v)=\frac12\|A-X\|_F^2+{\rm tr}(U^T(X-X^T))+v(1-{\rm tr}(X))$$ and from the condition $$\frac{∂L}{∂X}=0$$ the general form $$X=A+(U-U^T)+vI$$ To get trace $$1$$, you need $$1={\rm tr}(A)+n·v$$, the condition for $$U$$ is not that uniquely determined, only $$2(U-U^T)=A^T-A$$ has to be satisfied -- which is sufficient to uniquely determine $$X$$. The simple solution for that is $$U=A^T$$. Thus $$X=\frac12(A+A^T)+\frac1n(1-{\rm tr}(A))·I$$
• Could you explain in detail how you derived $X=A+(U-U^T)+vI$ and $2(U-U^T)=A^T-A$? Thank you! Commented Apr 14, 2015 at 11:55