# Projecting a symmetric matrix onto the space of linear operators with a particular eigenvalue

Specifically, I am interested in the case where one eigenvalue is exactly $$0$$. Given an $$n \times n$$ symmetric matrix, I would like to find the closest $$n\times n$$ symmetric matrix that has one eigenvalue that is equal to $$0$$.

Although the $$n\times n$$ matrices form a Hilbert space, the set of symmetric matrices with a zero eigenvalue is probably not convex, because the eigenvalues of a sum of two matrices has a complex relationship with the original matrices. Thus, the classic projection theorem does not guarantee a unique solution. However, I only need a solution. Since the eigenvalues of a matrix are continuous in the entries, the set of $$n\times n$$ matrices with a zero eigenvalue should be closed, and so the set of solutions shouldn't be totally insane.

In any case, how can I find the closest $$n\times n$$ symmetric matrix(es) with a zero eigenvalue to an arbitrary given $$n\times n$$ symmetric matrix?

• How do you define "closest"? Oct 3 '19 at 17:45
• @MichaelEngelhardt with whatever arbitrary metric on matrices. A handful can be gotten from the various matrix norms. For context, I am using this in a constrained optimization problem, so I perturb my original matrix a bit and it no longer has a zero eigenvalue, I want to get it back to having a zero eigenvalue, but not be too far away from where I started. If a particularly convenient solution happens to correspond to a particular metric, then that's the correct metric. :)
– Him
Oct 3 '19 at 18:17
• Ah, then it seems the answer that has already been given below is just the thing - great! Oct 3 '19 at 19:31

Any (real) symmetric matrix may be diagonalised by an orthogonal matrix. So let your matrix be $$A$$ and let $$O$$ be an orthogonal matrix such that $$D=OAO^{-1}$$ is diagonal. Note that the transformation $$A\mapsto OAO^{-1}$$ is distance preserving. Now get $$D'$$ by replacing whichever diagonal entry of $$D$$ has least absolute value, and let $$A'=O^{-1}D'O$$.