Why is unitary diagonalization works? I've been told that if you take an Hermitian matrix, find it's eigenvectors, normalize them and write them as columns of a matrix, $P$ then:
$$P^{-1}AP = D$$
Where (Magically) $D = \text{Diag}(\lambda_1,\ldots,\lambda_n)$ ($\lambda_i$ is an eigenvalue of $A$).
So I really want to use this algorithm but first I wish to understand why does this magic works?

By Schur decomposition, every square matrix $A$ is unitarily similar to an upper triangular matrix $U$. In particular if $A$ is Hermitian, then
$$U^* = (Q^* A Q)^* = Q^* A^* Q = Q^* A Q = U$$
which shows that $U$ is a diagonal matrix.
