I want to generate a random matrix $M$ that is non-diagonal, with negative eigenvalues, but diagonalizable into $V$, $D$, both with only real elements. I'm using SymPy for the diagonalization. (I'm trying also to have $V^T = V^{-1}$)
I'm generating $M$ as suggested here:
- Random matrix $\mathrm X \in \mathbb R^{n \times n}$
- $M = \left( \varepsilon \mathrm I_n + \mathrm X^\top \mathrm X \right)$ where $\varepsilon > 0$
Every time I diagonalize $M$ into $V$, $D$, either of them has complex values. Can I generate $M$ so that $V$, $D$ have only real numbers?
You can first randomly generate $D$, which completely determines the characteristic polynomial (that is, you see to it that the roots of the polynomial, which are precisely the entries of $D$, are just real negative numbers), and then you generate $V$ at random and then set $$ M = VDV^{-1}. $$ The important thing to observe here is the invariance of the characteristic polynomial under conjugation: $$ \det(VDV^{-1} - \lambda I) = \det(V(D - \lambda I)V^{-1}) = \det(D - \lambda I) $$ since the determinant is multiplicative.