Linear Algebra pt. 1
Introduction
The note is based on a MIT open course by professor Gilbert Strang. The note is to alter my perspective on matrices and spaces. Hopefully, at then end of the post, I will have some more insights in linear algebra, an essential subject for statistical algorithms.
Contents
- Matrices
- Spaces
- Projections
- Orthogonality
- Determinants
- Eigenvalues & Eigenvectors
Matrices
Intro to Matrices
Let us say there are two linear equations,
There are several ways to view this and one way would be by row picture which would plotting a 2-D plane graph with the top two linear equations (we’re quite experienced with this). However, we can also see this by column picture.
This picture can be illustrated into another 2-D plot with vectors. This equation is called the linear combination of columns and is often denoted as
It doesn’t seem so different when there are two equations, but when we think of situations with 3 equations, it is a lot more easier to think of a plot with 3 vectors (column picture) than 3 plane collision (row picture).
Coming back to the 2 equations, can we solve
The column picture allows us to see the linear equations into a combination of vectors which gives us a clear way to observe.
Elimination
Let us say there are 3 equations,
It is really difficult to plot vectors in head once the dimension eleveates. So humans have found out a way to solve linear equations by elimination.
This is also possible with the matrix augmenting the b column.
The last part is to seperate the matrix and the column and solve
Before trying to understand the mechanism hiding here, we need to understand the matrix multiplication.
4 Types of Matrix Multiplication
We will skip the dot product (row times column) part because it is a very simple process.
(1) is the outer product (column times row). Each of the multiplication of column and row is a matrix and the sum adds up to become C. (2) illustrates that the columns of C is the combination of columns of B
So, if we are trying to operate by columns in the right side of the equation, we need to multiply a matrix on the right. This leads to the answer why the equation below is true.
In addition, what the E matrices; elementary matrices are really doing is just applying multiplication + subtraction between rows. Therefore, we can infer there is some multiplication that would do the operation backwards; inverse.
-
Bonus: What if we there are times we need both row and column operation? Is there an order for it?
No.
-
Bonus 2: What if the second pivot is 0 after the E(2,1) progress?
We can exchange the row 2 and 3; permutation.
Inverse
So, we want a matrix that does exactly backwards what it does. If the matrix does its operation -> do it backwards, it is going to do nothing on the target matrix; identity matrix. It returns the exact matrix as you can see by thinking of the three types of multiplication from prior section.
So,
Just like the prior section (Ex 1), A is going to be manipulated by E into I. Coming back to the elimination, when we say there is no situation such as ‘Bonus2’,
The matrix L is a lower triangular matrix with 1’s in diagonal, and U is an upper triangular matrix.
However, there are times when there is no matrix that can be inversible. It is when
Additionally, there are some other important points.
Permutation
There are matrices that can exchange rows. Through with the permutation matrices we are able to improve the process of elimination. Think about the words below.
Multiplying identity matrix returns the original matrix. If we reorder the rows of an identity matrix, we can exchange rows of the original matrix.
Transpose
Symmetric matrices are extremely useful because we don’t have to know about the other side. However, how do we get those symmetric matrices?
With the knowledge of matrix multiplication we are ready to look at spaces.
Spaces
Intro to spaces
In linear algebra, we want to operate simple multiplication and addition to vectors. In a space of vectors; vector space, these operation should be allowed.
Let us say there is a vector space that is composed of all real vectors with 2 real components;
However, it is not very useful to always talk about the whole vector space. Most of the times, we want the space inside the vector space; subspace. By the definition of vector space (vector operation), possible subspaces of
where L is a line that goes through O; origin.
Subspace and Matrices
So how do subspaces come out of matrices?
Column Space
When there is a m by n matrix A, all the linear combination of columns form a subspace of
The reason we are interested in column spaces can be reviewed from above, “Intro to Matrices”; when we are trying to figure out an equation as below.
In other words, since the left side of the equation is about operations in column space, we are only able to solve the equation when b is in C(A). What we can also learn from the column space is that even though there are three real vectors with four components; subspace of
Null Space
The null space is the solutions to when the combination of column vectors are in origin.
We can see that the difference btw the null space and the column space is that,
- now we’re interested in vector x
- N(A) is a subspace of
Repeating, the null space is not the linear combination of columns but the solution which is a line in this case.
How do we find the special solution? The easiest way is to execute elimination.
The number of pivot columns are two; rank of A which are 1 and 3. And we have the free variable x2 and x4 which don’t matter what they are. If we apply each of the variables either 0 or 1, we can get the whole null space by combination of the vectors. Of course, the zero vector also works but since it is zero, it’s omitted.
To summarize, a null space is a combination of special solutions. And the number of solutions (nonzero vector) is equal to the number of free variables; dimension - # pivot variables; n-r.
- Bonus
When the number of free variables is nonzero, it means there is a solution to . This means the matrix A is not invertible; singular.
Coming back to column space
Since we obtained the complete solution for Ax=0, let us try Ax=b.
When b is a nonzero vector, the equation is only solvable when b is in C(A). If we set some particular number for b’s, we can solve the eliminated equation by setting all the free variables just like above. Therefore, we can summarize the whole solution as the combination of a particular solution (to particular b) and the solution to Ax=0.
If we categorize by rank of matrix that is m by n of rank r (r <= m, r<=n),
- full column rank (r=n)
pivot in every columns = no free variables = solutions to Ax=b: only zero vector if b exists; 0 or 1 solution - full row rank (r=m)
pivot in every rows = b has many outcomes = can solve Ax=b for every b: infinite solutions; infinite - full rank; square; invertible (r=m=n)
pivot in every columns & rows = b is 0: only zero vector; 1 solution
Therefore, the importance of rank rises when we are trying to figure out the number of special solutions.
Linear Independence & Spanning & Basis & Dimension
Independence
If vectors
So, the columns are independent to each other when there are no free variables; r = n. In contrast, they are dependent when there are free variables; r < n.
Spanning
Spanning to space is a mathematical term to indicate the linear combination of vectors. For example, the vectors
With these terms, we can define basis.
Basis
Basis for a space is a sequence of vectors that are independent to each other and that can span the space.
For example,
Given a space of R3, (1) can be defined as a basis of R3 since they are independent to each other and span to space. However, (2) can’t be since they can’t span to R3 but to R2 which is a plane. The number of basis; dimension are equal in the same space.
Reduced Row Echelon Form
Coming back to elimination, we need to ask ourselves, are we done?
The matrix R has two pivot columns, and one free column just as the original matrix but in a much more clean form. In the rows perspective, we only have independent rows and below are zero rows. Additionally, since there was only row operation, the null space hasn’t changed; not the column space.
This is very important because,
the first nonzero rows (there are r of them, just like pivot columns) are the basis for row space of A, which leads us to another step; 4 subspaces.
4 Subspaces
There are four major subspaces; Column space, Null space, Row space, Null space of A transpose (a.k.a the left null space). Assume there is a m by n matrix A,
We want to know the dimension of each space because we get a lot of information such as rank, basis during calculation of the process.
What about the left null space?
By row operation, we are able to get zero row. So, we need to know special solutions that would lead us to zero row by conducting row operation to A and we can attain this by using reduced row echelon form.
So, the last rows that would transform rows of A into zero rows would be the basis and the number of it (=free rows of R) would be the dimension of the left null space.
These 4 subspaces are going to be essential to understand the linear relation btw solutions and matrices in next further steps.