Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 18

Calculating Eigenvectors for 2x2 Matrices

Recommended resources

Introduction

In our previous lesson, we established a powerful algebraic method for finding the eigenvalues of a matrix. By solving the characteristic equation, , we could determine the exact scaling factors, , for a given linear transformation. However, this only gives us half the story—the "how much." It doesn't tell us which directions are so special that they remain on their own span.

This lesson completes the picture. We will now take the eigenvalues we've learned to calculate and use them to find their corresponding eigenvectors. You will learn to solve the equation for the vector . This procedure is the final computational step required to find the principal axes of variance in your data, a cornerstone of techniques like PCA that are central to your computational biology projects.


Finding Eigenvectors: Solving for the Null Space

Let's return to the equation that started our journey:

In the last lesson, our goal was to find the values of that make the matrix singular (i.e., have a determinant of zero). Now, we will work with those specific values of . For a known eigenvalue , the matrix is a concrete, numerical matrix. Our task is to find all the non-zero vectors that this singular matrix sends to the zero vector.

This is a problem you've encountered before: we are looking for the null space of the matrix . Because we chose specifically to make this matrix singular, we are guaranteed that its null space is non-trivial; it contains more than just the zero vector. In the context of eigenvalues, this null space is given a special name: the eigenspace corresponding to .

Every non-zero vector within this eigenspace is an eigenvector for that eigenvalue. For a 2x2 matrix, the eigenspace will typically be a line passing through the origin.


A Step-by-Step Calculation

Let's make this concrete with a calculation. We'll find the eigenvectors for the matrix . In a typical problem, you would first solve the characteristic equation to find the eigenvalues. Let's assume we have already done that and found the eigenvalues to be and .

Step 1: Find the eigenvector for

We need to solve the system .

First, construct the matrix :

Now, we solve the system . This gives us two equations:

Notice that both equations are equivalent; they both simplify to . This redundancy is expected! Since the matrix is singular, its rows are linearly dependent. This means we have a free variable. Let's say is free. If we set , then . So, the general solution is:

This is the eigenspace for . It's the line passing through the origin and the point (1, 1). Any non-zero vector on this line is a valid eigenvector. The simplest choice is to set , giving us the eigenvector .

The following resource provides a clear, step-by-step walkthrough of this exact calculation.

Eigenvectors and Eigenvalues — Linear Algebra, Geometry, and ...

This document from Boston University provides a clear computational walkthrough that directly mirrors the steps we just took.

Read the section titled Checking Eigenvectors, and then focus on the example immediately following, from finding the eigenvectors to the end of the section. This shows how solving the homogeneous system (A - 7I)\mathbf{x} = \mathbf{0} yields the eigenspace.

Step 2: Find the eigenvector for

Let's repeat the process for our second eigenvalue. We solve , which is .

Construct the matrix :

The system to solve is . This gives the single equation , or .

Again, we have a free variable, . To get a simple integer vector, we can choose . This gives . So, a representative eigenvector is . The full eigenspace is the line of all vectors .


Geometric Intuition and the ML Connection

We have now algebraically found the two special directions for our transformation . The direction is stretched by a factor of 7, and the direction is flipped and stretched by a factor of 4. All other vectors are some combination of these effects and are knocked off their original span.

On the left, a reflection matrix. Vectors on the line of reflection (green) are eigenvectors with eigenvalue \(\lambda=1\). Vectors perpendicular to it are eigenvectors with \(\lambda=-1\). On the right, a rotation matrix. In general, a rotation has no real eigenvectors, as every vector's direction is changed.

This process is not just a mathematical exercise; it's exactly what happens under the hood when you perform Principal Component Analysis (PCA). In your project on cancer genomics, your data might have thousands of features (genes). PCA helps you find the most important patterns in this high-dimensional space.

  1. You start with your data and compute its covariance matrix, let's call it .
  2. You solve the characteristic equation to find the eigenvalues. These eigenvalues tell you how much variance (i.e., information) is captured along each principal direction.
  3. You then do exactly what we did in this lesson: for each eigenvalue , you solve to find the corresponding eigenvector .
  4. These eigenvectors are the principal components. The eigenvector with the largest eigenvalue is the direction of maximum variance in your data. The second is the direction of maximum variance orthogonal to the first, and so on.

By projecting your data onto the first few principal components, you reduce its dimensionality while retaining the most significant patterns, which can then be used to train a more robust classifier for ALL vs AML.

The following video walks through this exact process for a 2x2 covariance matrix, showing how eigenvalues and eigenvectors are calculated and what they mean in a practical data science context.

PCA : the math - step-by-step with a simple example

This video from TileStats, "PCA : the math," provides an excellent step-by-step example that directly links the computation of eigenvectors to their role in PCA.

Watch the segment from calculating the eigenvectors. Pay close attention to how they plug a calculated eigenvalue back into the system of equations to solve for the components of the eigenvector, just as we did. Note that in practice, eigenvectors are often normalized to have a unit length of 1, which we will discuss more later.


Eigenspace Computation

The step-by-step procedure of finding eigenvalues and then the corresponding eigenspaces is fundamental. Let's look at one more concise resource that formalizes this.

[PDF] Mathematical Methods - Marc Deisenroth

This section from Deisenroth's "Mathematics for Machine Learning" provides a compact summary and another worked example of finding an eigenspace.

Please read the short subsection 5.11.2. Focus on the first example for the matrix A = \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}. Notice how it follows the exact two-step process: first, find the eigenvalue by solving the characteristic polynomial; second, compute the null space of (A - \lambda I) to find the eigenspace.


Conclusion

In this lesson, you've mastered the final piece of the puzzle for computing eigenvalues and eigenvectors. You now understand how to take a given eigenvalue and find the corresponding direction(s) of invariance by solving a homogeneous system of equations.

Key Takeaways:

  • To find the eigenvectors for a given eigenvalue , you must solve the equation .
  • The set of all solutions forms the eigenspace for , which is the null space of the matrix .
  • Because was chosen to make singular, this eigenspace is guaranteed to contain non-zero vectors.
  • In machine learning, the eigenvectors of a covariance matrix are the principal components, which define the axes of greatest variance in the data.

We've focused on the general procedure, but the matrices you'll encounter most often in ML, like covariance matrices, are of a special type: they are symmetric. These matrices have remarkable and convenient properties regarding their eigenvalues and eigenvectors. In our next lesson, we will explore why symmetric matrices always have real eigenvalues and why their eigenvectors are always orthogonal, a property that is essential for PCA to work as a change of basis.