Some Basics of Linear Algebra

The term algebra is often confused between what mathematicians would call “elementary algebra” and “algebra” in the more general sense. When we talk about “algebra,” we are thinking about it in the more general, high-level sense which includes “elementary algebra,” “linear algebra,” and “abstract algebra.” We’re going to talk about some of the basics of “linear algebra” which extends many of the concepts one learns in elementary algebra for scalar values, but extended to tensors: scalars, vectors, matrices, and higher-dimensional objects.

First of all, what types of objects are we going to be working with?

A scalar is just a number. For example someone’s height, a temperature, or the number of cows in a field. A vector has more than one dimension, for example a force has both magnitude and direction – the magnitude on its own is a scalar while the direction is determined by the components of the vector.

\[\begin{pmatrix} 1 \\ -3 \\ 2 \end{pmatrix}\]

We will also call this is a list. At its core, a list is simply an ordered collection of numbers. In the above case, we’ve got a list of length \(3\) consisting of three components: \(1\), \(-3\), and \(2\). This is a vector and we can think about as an arrow which extends from the origin, \((0, 0, 0)\) to \((1, -3, 2)\).

How do we figure out the magnitude of this vector? We use the Euclidean formula,

\[\ell = \sqrt{1^2 + (-3)^2 + 2^2} = \sqrt{1 + 9 + 4} = \sqrt{14} \, .\]

Note that we could actually calculate the magnitude or length of the vector by other formulae, which we generally call a norm. I discuss different types of norms in another post.

This tells us the “length” of the hypotenuse formed when we extend from the origin, \((0, 0, 0)\), to \((1, -3, 2)\).

v1 = [ 1, -3, 2 ]

norm(v1) == sqrt(14)
> true

When we combine multiple vectors, we can arrange them into a matrix.

\[I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\]

This is actually a fairly special matrix called an identity matrix which means that it funds very similar to the number \(1\). Whenever we multiply any vector with two components, this matrix will give us the same vector back. This is just like when we multiply a number by \(1\), we just get the same thing back.

[ 1 0 ; 0 1 ] * [ 2 ; 3 ] == [ 2 ; 3 ]

Let’s construct a matrix using three column vectors,

v1 = [ 1 ; -3 ; 2 ]
v2 = [ 0 ; 2 ; -1 ]
v3 = [ -2 ; 2 ; 0 ]

B = [ v1 v2 v3 ]

> 3×3 Matrix{Int64}:
  1   0  -2
 -3   2   2
  2  -1   0

In Julia, vectors are essentially just arrays and we can think about them like that too: an ordered list of numbers. Observe the difference between a set and an array or vector.

The set, \(s_1\) ,

\[s_1 = \{ 1, 2 \} = \{ 2, 1 \} \, ,\]

because a set is unordered. While the arrays \([ 1, 2 ]\) and \([2, 1]\) are not equal as the order of the \(1\) and \(2\) are different.

Set([2, 3]) == Set([3, 2])
> true

[2, 3] == [3, 2]
> false