Free preview
61 lessons
Essential Linear Algebra for ML
Free preview
Essential Linear Algebra for ML · 61 lessons
No surprise gaps
Actually remember it
Skip what you know
One subscription. All learning paths included.
Our content is best on a larger screen
What is a symmetric matrix?
A symmetric matrix is a square matrix that is equal to its own transpose. In other words, if is a symmetric matrix, then we have:
This means that the entry in row and column is the same as the entry in row and column , for all and . That is, .
For example, a matrix is symmetric if . So, a symmetric matrix looks like:
Similarly, a matrix is symmetric if , , and . It looks like:
The elements along the main diagonal (from top-left to bottom-right) can have any value, but the elements mirrored across this diagonal must be identical.
Determine which of the following matrices are symmetric:
Solution
Let's check each matrix in turn:
, so is symmetric.
, so is not symmetric.
, so is symmetric.
Practice questions
3 questions
Consider the following matrices:
Which of the following is true?
Select the correct answer:
+ 2 more questions
Orthogonal eigenvectors of symmetric matrices
Symmetric matrices have two fundamental properties:
1. All eigenvalues are real numbers.
If is symmetric, then every solution of is a real number. This means we never have to deal with complex eigenvalues when working with symmetric matrices.
2. The eigenvectors can be chosen to be orthonormal.
If is a symmetric matrix with two different eigenvalues , and corresponding eigenvectors and , then these eigenvectors are guaranteed to be orthogonal:
This means that eigenvectors associated with distinct eigenvalues always point in perpendicular directions. Even when eigenvalues are repeated, it is still possible to select eigenvectors that are mutually orthogonal.
Finally, by normalising each eigenvector to have length , we can obtain an orthonormal set of eigenvectors satisfying
In other words, every eigenvector in the set has unit length, and any two different eigenvectors are perpendicular (i.e. their dot product is ). Note we use the "hat" notation above a vector to denote that it's a unit vector.
Together, these properties make symmetric matrices especially well-behaved. Their eigenvectors form a clean, perpendicular coordinate system, and each eigenvector points along a direction that the matrix simply stretches or compresses.
Because the eigenvectors are orthogonal, these directions do not overlap or interfere with each other, which is why symmetric matrices are so useful in practice.
Visualisation
Have a play with the visualisation below.
The blue and red lines show the eigenvector directions of the symmetric matrix
ML Context
Symmetric matrices are everywhere in data science, for example:
In short: whenever we see a symmetric matrix in ML, we can rely on its eigenvalues being real and its eigenvectors forming a neat, orthonormal coordinate system.
Consider the symmetric matrix
The eigenvalues of are and , with corresponding eigenvectors
Solution
1. Check orthogonality
So the eigenvectors are orthogonal.
2. Normalise each eigenvector
The length of is:
So the unit vector, which we'll call , is given by:
The length of is:
So the unit vector, which we'll call , is:
The orthonormal set of eigenvectors, , of is therefore:
Practice questions
3 questions
Suppose a symmetric matrix has orthogonal eigenvectors:
Which of the following is an orthonormal set of eigenvectors for ?
Select the correct answer:
+ 2 more questions
Orthogonal diagonalisation of symmetric matrices
A key property of symmetric matrices is that they can always be written in a special form using their eigenvectors and eigenvalues. Specifically, if is a symmetric matrix, then there exists an orthogonal matrix and a diagonal matrix such that:
Here:
This way of writing is called orthogonal diagonalisation. It tells us that every symmetric matrix can be “simplified” into a diagonal form by choosing the right orthonormal eigenvectors.
Gotcha
In the decomposition :
If we change the order of eigenvalues in , we must reorder the columns of in the same way otherwise the eigenvalue–eigenvector pairs no longer match, and .
Details
Consider the symmetric matrix:
This matrix has eigenvalues , , with corresponding orthonormal eigenvectors:
Verify that can be written in the form:
where is an orthogonal matrix and is a diagonal matrix.
Solution
We form by putting the eigenvectors as the columns:
and by putting the corresponding eigenvalues on the diagonal:
We need to check that holds:
And so we have verified that can indeed be written in the form . This is an example of orthogonal diagonalisation.
Practice questions
3 questions
In the orthogonal decomposition, , of a symmetric matrix , what do the columns of represent?
Select the correct answer:
+ 2 more questions