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.
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 on a vector in
is a combination of stretching and rotation.
For example, in Figure 1,
matrix changed both direction and magnitude of vector ,
which resulted in the transformed vector .
However, for vector , only its magnitude changed after transformation.
and have the same direction.
Matrix only stretched in the same direction
and returned vector 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 and a scalar quantity ,
then has the same direction and a different magnitude as .
For a vector like in Figure 1,
the effect of multiplying by
is like multiplying it with a scalar quantity .
This is not universally true for all vectors in .
In fact, for a given matrix ,
only some vectors in have this property.
These special vectors are called the eigenvectors of matrix
and their corresponding scalar quantity is called
an eigenvalue of matrix for that eigenvector.
The eigenvector of an matrix is defined as a nonzero vector
such that:
where is a scalar and is called the eigenvalue of ,
and is the eigenvector corresponding to .
In addition, if you have any other vectors in the form of
where is a scalar,
then by placing it in the previous equation we get:
which means that any vector which has the same direction as the eigenvector
(or the opposite direction if is negative) is also an eigenvector
with the same corresponding eigenvalue.
For example, the eigenvalues of
are and and their corresponding eigenvectors are:
and we have:
This means that when we apply matrix to all the possible vectors,
it does not change the direction of two vectors — and
(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 using R.
# target matrixmat_b <-matrix(c(-1, 0, 1, -2), 2)
# calculate eigenvalues and eigenvectors for `mat_b`eigen_b <-eigen(mat_b)
eigen_b
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 is the same as ,
but the eigenvector for is different from .
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.