Given an arbitrary matrix, how to obtain a positive semidefinite matrix?

100 Views Asked by At

I m trying to make a simple program to generate random n by n matrices and then turn them to positive semidefinite. The way i thought of doing it was to create the matrix and then just simple multiply it with its transpose. If i remember by multiplying a matrix with its transpose it turns it to positive semidefinite. However when i print the eigenvalues i see that i still have negative ones, Is my idea wrong? Is there any way to turn any random matrix to positive semidefinite?

1

There are 1 best solutions below

2
On

Yes, your idea is right, as long as your matrices and vectors are real. I cannot comment on the randomness, though.

If $A^TAv=\lambda v$, then $$0\leq Av\cdot Av=(Av)^TAv=v^TA^TAv=\lambda v^Tv,$$ so $\lambda\geq0$.