# How to Project a Symmetric Matrix onto the Cone of Positive Semi Definite (PSD) Matrices

How would you project a symmetric real matrix onto the cone of all positive semi-definite matrices?

"A matrix M is positive semi-definite if and only if there is a positive semi-definite matrix B with B2 = M. This matrix B is unique, is called the square root of M, and is denoted with B = M1/2 (the square root B is not to be confused with the matrix L in the Cholesky factorization M = LL*, which is also sometimes called the square root of M). If M > N > 0 then M1/2 > N1/2 > 0."

 Horn & Johnson (1985), Theorem 7.2.6 with k = 2

Horn, Roger A.; Johnson, Charles R. (1990), Matrix Analysis, Cambridge University Press, ISBN 978-0-521-38632-6.

http://en.wikipedia.org/wiki/Positive-semidefinite_matrix

So, given symmetric $A,$ we have $A^2 = A A^T$ is symmetric positive semidefinite and has just one p.s.d. square root. So your projection is $$A \mapsto \sqrt{A^2}$$ Meanwhile, if $A$ is already p.s.d., already in the cone, then $A \mapsto A,$ which is what you want for something called a projection.

• This doesn't seem to be quite correct. Think in one variable -- the projection of $-1$ onto the semidefinite cone is $0$, not $|-1|=1.$ For symmetric $A$, however, the average $\frac{1}{2}(A+\sqrt{A^2})$ would work. – Justin Solomon Sep 7 '15 at 3:21

If you merely want to find a projection $\pi$ such that $\pi(S)$ is positive semidefinite for some fixed real symmetric matrix $S$, you may first orthogonally diagonalise $S$ as $QDQ^\top$ and then define $\pi: M\mapsto Q\Sigma Q^\top M$, where $\Sigma$ is a 0-1 diagonal matrix whose $i$-th diagonal entry is $1$ if the $i$-th diagonal entry of $D$ is nonnegative, and $0$ otherwise.

• @VictorDeplasse Your edit is problematic in two ways and I'm rolling it back. First, it should be a comment, not an edit. Second, your edit is wrong. On one hand, $\pi: M\mapsto Q\Sigma Q^top$, then $\pi$, as a linear operator, is a constant map, not a projection map. In fact, if you define $\pi$ this way, then $\pi^2\ne \pi$ in general. On the other hand, if you are talking about the projected image of $M$, then $\pi(M)$ should be $QD\Sigma Q^\top$, not $Q\Sigma Q^\top$. It is easy to see that $Q\Sigma Q^\top$ is a wrong choice, because $\pi(M)$ should be equal to $M$ if $M$ is PD. – user1551 May 20 '17 at 9:19