A diagonal matrix is a square matrix whose only potentially nonzero entries lie on the main diagonal; every off-diagonal entry is zero. In diagonalization, the diagonal entries are eigenvalues, so the matrix records how a transformation scales independent eigenvector directions. section 2.15
Diagonal matrices make geometric and computational structure easier to read:
- For a symmetric matrix, orthogonal eigenvectors form the change-of-coordinate matrix S, giving A = SΛSᵀ, where Λ is diagonal. section 2.15
- In a quadratic-form equation, a diagonal matrix describes an axis-aligned ellipse or hyperellipse; rotating coordinates can reveal this form. section 2.17
- The diagonal entries preserve the directional scaling while removing cross-terms such as xy from the transformed ellipse equation. section 2.17.1
A rotated ellipse
The ellipse 5x² + 6xy + 5y² = 20 has matrix A = [[5, 3], [3, 5]]. Computing its eigenvectors with torch.linalg.eig produces a rotation S; in the rotated coordinates, SᵀAS is diagonal, and the major axis forms a 45° angle with the x-axis. section 2.17.1
Figure 2.16 Note that the ellipse’s major axis forms an angle of 45 degrees with the X-axis. Rotating the coordinate system by this angle will align the ellipse axes with the coordinate axes. Subsequently, the first principal vector will also lie along this direction.
Use the figure to connect diagonalization with the geometric alignment of a hyperellipse's axes. section 2.17.1

