Eigenvector: An eigenvector of a square matrix \(A\) is a nonzero vector \(v\) such that when \(A\) is multiplied by \(v\), the direction of \(v\) remains unchanged. Mathematically, this relationship is defined as \(Av = \lambda v\), where \(\lambda\) is a scalar known as the eigenvalue associated with the eigenvector \(v\).
Eigenvalue: The scalar \(\lambda\) in the equation \(Av = \lambda v\) is the eigenvalue corresponding to the eigenvector \(v\). It represents the factor by which the eigenvector is scaled during the transformation.
The action of a matrix on its eigenvector can be visualized geometrically as stretching or compressing the vector along its direction, or rotating it in space. The eigenvalue specifies the scale of this transformation, indicating how much the vector’s length changes. Among all possible vectors in a space, eigenvectors are unique because they are the ones that, after the transformation is applied, remain on their own span (line through the origin); they may get stretched or compressed but don’t change their direction.
The calculation involves several steps:
Characteristic Equation: Start by finding the characteristic equation of matrix \(A\), which is obtained by subtracting \(\lambda\) times the identity matrix \(I\) from \(A\) and setting the determinant to zero: \(\det(A - \lambda I) = 0\).
Solve for \(\lambda\): Solve the characteristic equation for \(\lambda\). The solutions are the eigenvalues of \(A\).
Find Eigenvectors: For each eigenvalue \(\lambda\), solve the equation \((A - \lambda I)v = 0\) for vector \(v\). Each non-trivial solution \(v\) is an eigenvector associated with \(\lambda\).
Let’s illustrate these concepts with a simple example. Consider a \(2 \times 2\) matrix \(A\):
\[ A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix} \]
The characteristic equation of \(A\) can be found by setting the determinant of \(A - \lambda I\) equal to zero, where \(I\) is the identity matrix and \(\lambda\) represents an eigenvalue of \(A\). This gives:
\[ \det(A - \lambda I) = \det \left( \begin{array}{cc} 4-\lambda & 1 \\ 2 & 3-\lambda \end{array} \right) = 0 \]
Expanding the determinant, we have:
\[ (4-\lambda)(3-\lambda) - (1)(2) = 0 \]
Simplifying, we get the quadratic equation:
\[ \lambda^2 - 7\lambda + 10 = 0 \]
To find the eigenvalues, we solve the quadratic equation:
\[ \lambda^2 - 7\lambda + 10 = 0 \]
Factoring or using the quadratic formula, we find the roots (eigenvalues) \(\lambda_1\) and \(\lambda_2\):
\[ \lambda_1 = 5, \quad \lambda_2 = 2 \]
For each eigenvalue \(\lambda\), we find the corresponding eigenvector by solving \((A - \lambda I)v = 0\).
Substitute \(\lambda_1\) into \(A - \lambda I\):
\[ A - 5I = \begin{pmatrix} -1 & 1 \\ 2 & -2 \end{pmatrix} \]
Solving \((A - 5I)v = 0\) gives:
\[ \begin{align*} -x + y &= 0 \\ 2x - 2y &= 0 \end{align*} \]
Choosing \(x = 1\) leads to \(y = 1\), so an eigenvector corresponding to \(\lambda_1 = 5\) is:
\[ v_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix} \]
Normalizing \(v_1\), we get approximately:
\[ \frac{v_1}{\|v_1\|} = \frac{\begin{pmatrix} 1 \\ 1 \end{pmatrix}}{\sqrt{1^2 + 1^2}} = \frac{\begin{pmatrix} 1 \\ 1 \end{pmatrix}}{\sqrt{2}} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix} = \begin{pmatrix} 0.7071 \\ 0.7071 \end{pmatrix} \]
Substitute \(\lambda_2\) into \(A - \lambda I\):
\[ A - 2I = \begin{pmatrix} 2 & 1 \\ 2 & 1 \end{pmatrix} \]
Solving \((A - 2I)v = 0\) gives:
\[ \begin{align*} 2x + y &= 0 \\ 2x + y &= 0 \end{align*} \]
Choosing \(y = -2x\), and if we take \(x = 1\), then \(y = -2\), so an eigenvector corresponding to \(\lambda_2 = 2\) is:
\[ v_2 = \begin{pmatrix} 1 \\ -2 \end{pmatrix} \]
Normalizing \(v_2\), we get approximately:
\[ \frac{v_2}{\|v_2\|} = \frac{\begin{pmatrix} 1 \\ -2 \end{pmatrix}}{\sqrt{1^2 + (-2)^2}} = \frac{\begin{pmatrix} 1 \\ -2 \end{pmatrix}}{\sqrt{5}} = \begin{pmatrix} \frac{1}{\sqrt{5}} \\ \frac{-2}{\sqrt{5}} \end{pmatrix} = \begin{pmatrix} 0.4472 \\ -0.8944 \end{pmatrix} \]
For the matrix \(A\), we found:
Eigenvalues: \(\lambda_1 = 5\), \(\lambda_2 = 2\)
Eigenvectors: For \(\lambda_1 = 5\), the eigenvector is approximately \(\begin{pmatrix} 0.7071 \\ 0.7071 \end{pmatrix}\), and for \(\lambda_2 = 2\), the eigenvector is approximately \(\begin{pmatrix} 0.4472 \\ -0.8944 \end{pmatrix}\).
To calculate eigenvalues and eigenvectors in R, we can use the
eigen()
function. This function takes a square matrix as
input and returns a list containing the eigenvalues and eigenvectors of
that matrix. Let’s apply this to our example matrix \(A\).
# Define the matrix A
A <- matrix(c(4, 1, 2, 3), nrow = 2, byrow = TRUE)
# Calculate eigenvalues and eigenvectors
eigen_result <- eigen(A)
# Display the eigenvalues
print(eigen_result$values)
## [1] 5 2
# Display the eigenvectors
print(eigen_result$vectors)
## [,1] [,2]
## [1,] 0.7071068 -0.4472136
## [2,] 0.7071068 0.8944272
The eigenvalue \(\lambda_1 = 5\) corresponds to an eigenvector that points in the direction approximately given by \(\begin{pmatrix} 0.7071 \\ 0.7071 \end{pmatrix}\). This means that when the matrix \(A\) acts on this eigenvector, it stretches the vector by a factor of 5 without changing its direction.
Similarly, the eigenvalue \(\lambda_2 = 2\) is associated with an eigenvector approximately \(\begin{pmatrix} -0.4472 \\ 0.8944 \end{pmatrix}\), indicating that this direction is scaled by a factor of 2 when transformed by \(A\).
Eigenvalues and eigenvectors play a crucial role in understanding the behavior of linear transformations represented by matrices. This section provides a visual intuition behind these concepts using R.
First, let’s load the libraries and define a function to plot vectors, which will be used to display eigenvectors and their transformations.
library(ggplot2)
library(gridExtra) # For arranging the plots
# Define a function to plot vectors (eigenvectors or transformed vectors)
plot_vectors <- function(vectors, title) {
df <- data.frame(x = c(0, 0), y = c(0, 0),
dx = c(vectors[1, 1], vectors[1, 2]),
dy = c(vectors[2, 1], vectors[2, 2]))
p <- ggplot() +
geom_segment(aes(x = x, y = y, xend = x + dx, yend = y + dy),
data = df, arrow = arrow(type = "closed"), color = "red") +
xlim(-1, 5) + ylim(-1, 5) +
labs(title = title) +
theme_minimal()
return(p)
}
Now, we visualize the eigenvectors of \(A\), the effect of \(A\) on a set of grid points, and how \(A\) transforms its eigenvectors.
# Plot A's eigenvectors
p1 <- plot_vectors(eigen_result$vectors, "Eigenvectors of A")
# We simulate the effect of A by transforming a set of grid points
# Define a grid of points
x <- seq(-1, 1, length.out = 10)
y <- seq(-1, 1, length.out = 10)
grid <- expand.grid(x = x, y = y)
# Transform each point by matrix A
transformed_grid_A <- as.data.frame(t(A %*% rbind(grid$x, grid$y)))
# Plotting the effect of A on points
p2 <- ggplot() +
geom_point(aes(x, y), data = grid, color = "blue", alpha = 0.5) +
geom_point(aes(V1, V2), data = transformed_grid_A, color = "red", alpha = 0.5) +
xlim(-5, 5) + ylim(-5, 5) +
labs(title = "Effect of A on Points") +
theme_minimal()
# Plot transformed eigenvectors
transformed_vectors <- A %*% eigen_result$vectors
p3 <- plot_vectors(transformed_vectors, "Transforming A's Eigenvectors by A")
# Arrange the plots side by side
grid.arrange(p1, p2, p3, ncol = 3)