A vector may have many definitions: a point in space, an ordered list of numbers, a quantity with magnitude and direction, etc. More abstractly, a vector is simply an element of a vector space. All these diverse things are gathered under the common name of vector because, for certain types of questions, a common way of reasoning can be applied to all of them.
A vector can be written in matrix notation:
The magnitude of a vector (
A unit (normalized) vector (
We can use these two components to re-create the original vector by multiplying the unit vector by the length of the original vector:
Graphically, we can think of adding two vectors together as placing these vectors so the tail of the second one sits on the tip of the first one. The sum is a vector drawn from the origin to the tip of the second vector.
Vector subtraction works similarly. We place the tip of the smaller vector to sit on the tip of the bigger one and draw the result vector from the origin to the tail of the smaller vector.
Numerically, we add/subtract vectors component by component:
Graphically, we multiply a vector by a number (scalar) to either stretch or squish the vector (scale it). Multiplying a vector by a negative number also flips its direction.
Numerically, we multiply/divide every vector's component by the number:
Linear combinations of vectors are obtained by using vector addition and
vector scalar multiplication. For example, a linear combination of vectors
Vectors are said to be linearly dependent if there exists a nontrivial (where scalars are not all zero) linear combination of the vectors that equals the zero vector:
If the set of vectors is infinite, the vectors in it are considered to be linearly dependent if the set contains a finite subset that is linearly dependent.
Graphically, vectors are linearly dependent if two vectors are on the same line (for 2D) or if three vectors are on the same plane (for 3D). It means that one vector can be expressed as a linear combination of the other/s. The maximum number of possible linearly independent vectors is the same as the dimension of the vector space.
The span of vectors is the set of all their linear combinations. The basis of a vector space is a set of linearly independent vectors that span the full space. For example, by using linear combinations of any two linearly independent vectors, we can create any vector in the 2D space.
The basis vectors in the [1.5, 0.5]
can be described this way:
A vector space
To have a vector space, the eight following axioms must be satisfied:
- Associativity of vector addition:
$\vec{u} + (\vec{v} + \vec{w}) = (\vec{u} + \vec{v}) + \vec{w}$ ; - Commutativity of vector addition:
$\vec{u} + \vec{v} = \vec{v} + \vec{u}$ ; - Identity element of vector addition (zero vector
$\vec{0}$ ):$\vec{v} + \vec{0} = \vec{v}$ ; - Inverse elements of vector addition:
$\vec{v} + (-\vec{v}) = \vec{0}$ ; - Compatibility of scalar multiplication with field multiplication:
$a(b\vec{v}) = (ab)\vec{v}$ ; - Identity element of scalar multiplication:
$1\vec{v} = \vec{v}$ ; - Distributivity of scalar multiplication with respect to vector addition:
$a(\vec{v} + \vec{u}) = a\vec{v} + a\vec{u}$ ; - Distributivity of scalar multiplication with respect to field addition:
$(a + b)\vec{v} = a\vec{v} + b\vec{v}$ .
Usually, we work with real vector spaces
A field
Numerically, the dot product can be calculated by multiplying vectors component-by-component and then adding the results:
The result of dot product is always a scalar.
This formula can be extended to work with N-dimensional vectors, but can't be used with more than two vectors:
Geometrically, we can calculate dot product using another formula, which comes from the Law of Cosines:
The purpose of the dot product is to give us useful information about angles and lengths simultaneously. For
example, we use the dot product to calculate the work
In some cases, we don't care about the length, we only care about how much vectors are pointing in the same
direction. In this case, it's a lot easier to work with unit vectors. The dot product of two unit vectors equals
the cosine value of the angle between them. There are three most important angles for cosine:
Let's start with 3D geometric representation first. The cross product of two
linearly independent vectors
where
The cross product of vectors in 2D space is not exactly defined. But its magnitude can still be calculated. The
magnitude of the cross product equals the area of a parallelogram with the vectors for sides. The result of the cross
product for two vectors in 2D space
Unlike the dot product, the cross product says how different vectors are, but with a nuance. The cross product of two vectors is the biggest when they are perpendicular to each other.
Also, pay attention that the cross product is anticommutative:
The cross product is commonly used in computer graphics to calculate the normal for a triangle or polygon or in physics to calculate angular momentum and torque.
Finally, let's calculate the cross product of two vectors numerically, using their components. The cross product can be expressed in matrix notation as a formal determinant:
Geometrical representation of both dot product and cross product can be used to calculate an angle between two vectors:
A matrix is a collection of numbers, just like a vector. The difference is that a matrix is a table of numbers rather than a list. We can think of vectors as matrices that have only one column/row.
A real matrix
To add/subtract matrices, they have to be the same size:
When multiplying/dividing matrices, they don't need to be the same size. In order to multiply two matrices
Linear Transformation (or Linear Map) is a function from one vector space to another that respects the underlying linear structure of each vector space.
Numerically, this looks like a matrix-vector dot product, the result of which is a vector:
Graphically, in 2D/3D, a vector can be stretched, squeezed, rotated, sheared, reflected, and projected onto something, or a mix of all/some of these. Also, the matrix columns show where unit vectors will be after the transformation is applied.
For this transformation to be linear, a couple of conditions must remain true after the transformation:
- All lines (even diagonal) must remain lines after the transformation;
- Grid lines must be parallel and evenly spaced;
- Origin must be on the same place.
In a square matrix, each component is responsible for different transformations. For example, in a
Composition is accomplished by matrix multiplication:
For example, to apply stretching and rotation matrices, we can multiply them and apply the resulting matrix. It gives us the same result as applying them one by one:
Interesting moment: a vector is scaled up a bit during rotations by acute angles (because we actually use both
A square matrix is called invertible, if the product of the matrix and its inverse is the identity (or unit) matrix:
In other words, an invertible matrix
Numerically, linear transformation can be executed in any dimensions as shown in the formula. But it's not easy to show the transformations graphically in dimensions other than 2D and 3D.
In linear transformations, a dimension of codomain may be different from the dimension of domain. For example, we can use a matrix with only one row (or just put zeros in the second row) to "reduce" the dimension of vectors from 2D to 1D:
The set of vectors that land on the origin after such transformations is called null space or the kernel of the matrix.
The dimension of codomain
In linear algebra, the rank of a matrix
The determinant
- The determinant is nonzero if and only if the matrix is invertible (for example, reducing dimensions gives zero determinant);
- The determinant shows how much a region/area is stretched or squished after the transformation (works for volumes in 3D);
- The negative determinant shows that the orientation has been reversed.
$\det(I) = 1$ $\det(AB)=\det(A)\det(B)$
Numerically, the determinant can be calculated using a formula:
And for 3D:
The formula can be generalized for
It's actually easier to think about vectors as points in space to visualize transformations. These points can trace out simple objects or even complicated shapes. The math behind these visualizations stays the same, so we can apply transformations to all of these points and thus, to the shape.
Unlike a linear transformation, an affine transformation doesn't need to preserve the origin of the affine space. This allows us to move or even to change the perspective of the shapes.
Visually, to perform an affine transformation on the 2D plane, we can perform a linear transformation in 3D with the 2D
plane placed on the index
Numerically, you have to use homogeneous coordinates, which basically means to add an extra dimension
or for 3D:
To match the dimensions, another row and column must be added to the matrix to perform a linear transformation. Here's an example of 2D translation using homogenous coordinates (again, it's actually a 3D shear):
A vector addition may also be used to do translations. Using homogeneous coordinates over vector addition gives many advantages, such as decreasing the number of operations, combining multiple transformations and translations into a single matrix (don't forget that order matters), etc.
Graphically, an eigenvector is the vector that doesn't change the direction after the linear transformation (but can be scaled and even flipped):
Numerically, the eigenvector must satisfy the following equation:
where
The only way it's possible for non-zero vector
We need to solve for which eigenvalues this expression is true. Then, put the eigenvalues into the eigenvector expression and find eigenvectors for which that one is true.
A matrix can have multiple eigenvectors. Also, it doesn't mean that every matrix has eigenvectors. Some of them don't (for example, 2D rotation matrices).
Eigenvectors make understanding linear transformations easy. They are used in Computer Vision, mathematical problems that can be modeled with linear transformations, and even Google PagerRank algorithm.
A Linear System of Equations is a collection of one or more linear equations involving the same variables. The number of equations must be the same as the number of unknown variables:
The same equation can be written in a vector form:
or:
The vector
There are many algorithms that solve linear equations numerically. Arguably, the most popular one is the Gaussian Elimination algorithm.
Graphically, solving the system of linear equations is finding a vector
Another option is to draw equation graphs and find their intersection point (or an intersection point of planes in 3D):
The determinant of the matrix above is not zero, which is why we have a single solution (intersection). In the zero-determinant cases, the transformation associated with the system of equations squishes space into a smaller dimension, so there's no inverse transformation. In this case the system has either infinitely many solutions or no solutions.