In simple 2D, you can think of the components as the x-component and y-component...
...but we can also go to as many dimensions as we want.
If you have a collection of vectors, you call them a set. The only restriction here is no duplicates.
Another important term is a linear combination: a vector produced scaling and/or adding vectors.
The span of a set is ALL possible linear combinations of its vectors. As an example, the span of a singular vector is a line (scaling up and down to infinity).
So what about the span of two vectors? A plane? Not always. That depends on a little something called linear independence.
These two vectors are linearly independent, so the span is a plane...
...but these two are not. They are linearly dependent because \(\vec{y}\) is a linear combination of \(\vec{x}\) (specifically, \(\vec{y}\) is a scaled copy of \(\vec{x}\), and vice versa).
So what exactly is linear independence? Basically, vectors in a set are not redundant.
There are a few ways to think about it:
the number of vectors matches the dimension of the span (in the first example, 2 vectors making a 2-D plane = linearly independent)
each vector brings a new direction to the set (in the second example, \(\vec{y}\) does not bring a new direction to \(\vec{x}\) = NOT linearly independent)
The super formal definition is that a linear combination of the vectors equals zero is if and only if ALL the coefficients are zero.
A matrix is a grid with \(m\) rows and \(n\) columns of elements (not components), labeled by their row, then their column.
For our sake, a matrix is a function that acts on a vector. Input a vector, output a vector. For our sake, the calculations are not important.
First off, the height of your vector must match the width of your matrix. Otherwise everything breaks.
The process for each row:
multiply the first \(A\) element by the first \(\vec{x}\) component
multiply the second \(A\) element by the second \(\vec{x}\) component
multiply the third \(A\) element by the third \(\vec{x}\) component
...you get the idea
then add each row up and you're done!
So you put in a vector of size \(n\), and output a vector of size \(m\).
Need a more concrete example? Here you go!
The important thing, though, is that matrices are linear operations! Hence, the name linear algebra. That means vector addition and scalar multiplication can be moved through the operator:
Yippee! This is a super useful property that doesn't happen very often. For example, the easy function \(f(x) = x^2\) is not linear, because \(f(2x) ≠ 2f(x)\).
And that's it for the basics!
Matrices as Transformations ->
Matrices stretch vectors in a certain direction. Let's look at some examples in 2D.
The identity matrix (\(0\) everywhere except \(1\)s on the diagonal) does nothing to the vector. Useless.
Now try moving the dot around.
By scaling the \(1\)s, we can manipulate how the matrix transforms our vector.
AKA, the unit circle. This includes all the vectors with magnitude \(1\) in every single direction (in 2D).
We've been working mostly with one vector made of two components.
Now, we're going to think of every vector as a linear combination of the components to see how a matrix stretches all vectors.
Scaling
Rotating
Reflecting
Of course, we can combine all of these into one. Take a look at this matrix transformation:
You might notice that the bold vectors stay pointing in the same direction, even after they are transformed. They're only scaled up and down.
These are called eigenvectors \(\vec{u}\). The amount they're scaled is called an eigenvalue \(\lambda\). Because the matrix just scales \(\vec{u}\) by \(\lambda\), we can say:
The spectral radius of a matrix is the largest eigenvalue magnitude (absolute value).
We let the horizontal axis direction be \(\vec{v_1}\) and the vertical axis direction be \(\vec{v_2}\)
Scaling: Eigenvectors are \(\vec{v_1}\) (with eigenvalue \(k_1\)) and \(\vec{v_2}\) (with eigenvalue \(k_2\))
Rotating: Because all vectors are rotating, it may seem like no vector can be an eigenvector—but that just means the eigenvectors complex numbers! So we can't visualize them on our real axis.
Reflecting: Eigenvectors are \(\vec{v_1}\) (with eigenvalue \(1\) because it stays exactly the same) and \(\vec{v_2}\) (with eigenvalue \(-1\) because it's flipped)
Every vector \(v\) can be written as a liner combination of the eigenvectors. In other words, we can think of each eigenvector as our "componnents."
That means we can write the transformation of every vector \(Av\) as a linear combination of the transformed eigenvectors. This is what allows us to warp the unit circle in the way we did above.
Each matrix can be decomposed into 3 matrices using it's eigenvectors and eigenvalues:
\(D\) is a matrix with the eigenvalues along the diagonal and zeroes everywhere else.
\(Q\) is a matrix with the normalized eigenvectors as its columns. (\(Q^T\) is the tranpose of \(Q\), meaning flipped along the diagonal.)
This decomposition is how the vectors and ellipses on the next page are calculated.
Now, those are big words, complicated matrices, and weird symbols. So I've created an interactive experience where you can click and drag eigenvectors, and see how it changes the matrix in real time.
Interact in 2D ->
unit circle
transformed
inverse
eigenvectors
This is the ball, but fancier:
green lines = transformed vectors
blue lines = connect to unit circle vectors
white lines = inverse (applied to unit circle)
Drag around the eigenvectors to manipulate the matrix—you'll notice that the eigenvectors will always be parallel to the blue unit circle lines.
Oh no, your window is too small! Please view on laptop or desktop.