Singular Value Decomposition - Eigenvalue


matrix , updated 2021-11-18

In the last post, I described matrix as a transformation mapped onto one or multiple vectors. In this sequel, we continue building the foundation that leads to Singular Value Decomposition.

Eigenvalues and Eigenvectors

circle and ellipse
A circle (left) and a ellipse after transformation (right), as seen in the previous post.

A vector is an entity which has both magnitude and direction. The general effect of matrix A on a vector in X is a combination of stretching and rotation. For example, in Figure 1, matrix A changed both direction and magnitude of vector x1, which resulted in the transformed vector t1. However, for vector x2, only its magnitude changed after transformation. x2 and t2 have the same direction. Matrix A only stretched x2 in the same direction and returned vector t2 which has a bigger magnitude.

The only way to change the magnitude of a vector without changing its direction is by multiplying it with a scalar. For example, we have a vector u and a scalar quantity λ, then λu has the same direction and a different magnitude as u. For a vector like x2 in Figure 1, the effect of multiplying by A is like multiplying it with a scalar quantity λ.

t2=Ax2=λx2

This is not universally true for all vectors in X. In fact, for a given matrix A, only some vectors in X have this property. These special vectors are called the eigenvectors of matrix A and their corresponding scalar quantity λ is called an eigenvalue of matrix A for that eigenvector. The eigenvector of an n×n matrix A is defined as a nonzero vector u such that:

Au=λu

where λ is a scalar and is called the eigenvalue of A, and u is the eigenvector corresponding to λ. In addition, if you have any other vectors in the form of au where a is a scalar, then by placing it in the previous equation we get: A(au)=aAu=aλu=λ(au)

which means that any vector which has the same direction as the eigenvector u (or the opposite direction if a is negative) is also an eigenvector with the same corresponding eigenvalue. For example, the eigenvalues of B=[1102] are λ1=1 and λ2=2 and their corresponding eigenvectors are:

u1=[10]

u2=[11]

and we have:

Bu1=λ1u1Bu2=λ2u2

This means that when we apply matrix B to all the possible vectors, it does not change the direction of two vectors — u1 and u2 (or any vectors which have the same or opposite direction) — but only stretches them. For eigenvectors, matrix multiplication turns into a simple scalar multiplication.

Next, we calculate eigenvalues and eigenvectors of B using R.

# target matrix
mat_b <- matrix(c(-1, 0, 1, -2), 2)
# calculate eigenvalues and eigenvectors for `mat_b`
eigen_b <- eigen(mat_b)
eigen_b
eigen() decomposition
$values
[1] -2 -1

$vectors
           [,1] [,2]
[1,] -0.7071068    1
[2,]  0.7071068    0

We used function eigen() from base R to calculate the eigenvalues and eigenvectors. It returned a list. The first element of this list is a vector that stores the eigenvalues. The second element is a matrix that stores the corresponding eigenvectors.

Note that the eigenvector for λ2=1 is the same as u2,

[10]

but the eigenvector for λ1=2 is different from u1. That is because eigen() returns the normalized eigenvector. A normalized vector is a unit vector whose magnitude is 1. Before explaining how to calculate the magnitude of a vector, we need to learn the transpose of a matrix and the dot product, which will be the topic of my next post.