Prove that every quadratic form can be written as $\mathbf{x}^T A \mathbf{x}=\|\mathbf{x}\|^2\left(\sum_{i=1}^n \lambda_i \cos ^2 \theta_i\right)$, where $\lambda_i$ are the eigenvalues of $A$ and $\theta_i=\Varangle\left(\mathbf{x}, \mathbf{v}_i\right)$ denotes the angle between $\mathbf{x}$ and the $i^{\text {th }}$ eigenvector.