Thanks a lot for your answer. I tried to increase the precision of the solver in cvx toolbox, I set it to high, but the problem still remains.
I also tried to use your method, but it doesn’t help,too. When I tried to choose epsilon from 1e-3 to 1e-8, the computed eigenvalues are still negative. When I increased epsilon, made it bigger, like 0.1 to 1e-2, solver can’t solve the problem, the result is NaN.
I don’t know if the numerical error is related to the rank of matrix a’x+x’a-a’a, because normally in my case, it’s not full rank.