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](https://en.wikipedia.org/wiki/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](https://mathoverflow.net/questions/4224/eigenvalues-of-matrix-sums) with the original matrices. Thus, the [classic projection theorem](https://en.wikipedia.org/wiki/Hilbert_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?



Projecting a symmetric matrix onto the space of linear operators with a particular eigenvalue
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$.


([Nathaniel Johnston](https://mathoverflow.net/users/11236/nathaniel-johnston)'s [comment](https://mathoverflow.net/questions/343072/projecting-a-symmetric-matrix-onto-the-space-of-linear-operators-with-a-particul/343077?noredirect=1#comment857707_343077) let me find the related paper "[Low-Rank Positive Approximants of Symmetric Matrices](https://file.scirp.org/pdf/ALAMT_2014092513143053.pdf)" by Achiya Dax.)


