Let $A$ be a $n\times n$ square symmetric matrix. In addition, $A\succeq0$ and $\mathrm{rank}(A)<n$. This means that all eigenvalues are non-negative, but also that there are some zero eigenvalues. I want to perform quadratic optimization of the functional
$$
\frac{1}{2}x^HAx+b^Hx
$$
under convex conditions $x\_i\geq0$ and $y^Hx=0$, where $b,y$ some fixed vectors.

The problem arises when, due to numerical rounding errors, the matrix has some very small negative spurious eigenvalues. Then, then functional becomes unbounded. I have tried this with [SeDuMi](http://sedumi.ie.lehigh.edu/) and with matrix 
$$
A=\begin{bmatrix}10&17&25&-5&-9\\
17 & 29 & 43 & -9 & -16\\
25 & 43 & 65 &-15 &-26\\
-5 & -9 & -15 & 5 & 8\\
-9 & -16 & -26 & 8 & 13
\end{bmatrix},\quad
b=-\begin{bmatrix}1\\1\\1\\1\\1
\end{bmatrix},\quad
y=\begin{bmatrix}
1\\1\\1\\-1\\-1
\end{bmatrix}
$$
If you calculate the rank with MATLAB you will get $\mathrm{rank}(A)=2$. However, the numerical calculation with the help of the `eig()` function gives following results:

```
>> eig(A)

ans =

 -1.6661e-014
 -4.4496e-016
  4.2249e-015
       5.0536
       116.95

```

SeDuMi (via [Yalmip](https://yalmip.github.io/), excuted in Matlab 2007b) gives following error message:

```
Exiting: the solution is unbounded and at infinity;
 the constraints are not restrictive enough.

```

Do you have any idea, how to effectively address this problem numerically? I have tried diagonalizing $A$ and replacing the small negative eigenvalues with arbitrary small positive numbers, but this seems, well ... arbitrary, and I fear that it might produce numerical errors in the optimization. What do you think?