Skip to content

Chapter 1 — Vectors, matrices, and linear systems

After expressions (Volume 1) and linear functions (Volume 2), we move to the language of Linear Algebra. Here we represent multiple equations in a compact way using vectors and matrices.

1.1 Vectors in \(\mathbb{R}^2\) and \(\mathbb{R}^3\)

A vector in \(\mathbb{R}^2\) can be written as

\[ \mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} \]

Example vectors:

\[ \mathbf{u}=\begin{bmatrix}1\\2\end{bmatrix}, \quad \mathbf{v}=\begin{bmatrix}3\\-1\end{bmatrix} \]

Vector addition:

\[ \mathbf{u}+\mathbf{v}=\begin{bmatrix}1+3\\2+(-1)\end{bmatrix}=\begin{bmatrix}4\\1\end{bmatrix} \]

Scalar multiplication:

\[ 2\mathbf{u}=\begin{bmatrix}2\\4\end{bmatrix} \]

A quick extension to \(\mathbb{R}^3\) is \(\mathbf{w}=\begin{bmatrix}1\\0\\-2\end{bmatrix}\), where each entry is one coordinate component.

1.2 Matrices and system notation

A matrix \(A\in\mathbb{R}^{2\times 2}\) can be written as

\[ A=\begin{bmatrix}2 & 1\\1 & -1\end{bmatrix} \]

and we define

\[ \mathbf{x}=\begin{bmatrix}x_1\\x_2\end{bmatrix}, \quad \mathbf{b}=\begin{bmatrix}5\\1\end{bmatrix} \]

Then the linear system is represented by

\[ A\mathbf{x}=\mathbf{b} \]

which corresponds to the scalar form:

Equation Scalar form
1 \(2x_1 + x_2 = 5\)
2 \(x_1 - x_2 = 1\)

1.3 Worked example: solving a linear system

Solve the system

\[ \begin{cases} 2x_1 + x_2 = 5 \\ x_1 - x_2 = 1 \end{cases} \]

Add the equations:

\[ 3x_1 = 6 \Rightarrow x_1=2 \]

Substitute into \(x_1-x_2=1\):

\[ 2-x_2=1 \Rightarrow x_2=1 \]

Vector solution:

\[ \mathbf{x}=\begin{bmatrix}2\\1\end{bmatrix} \]

Matrix verification (short derivation)

\[ \begin{aligned} A\mathbf{x} &= \begin{bmatrix}2 & 1\\1 & -1\end{bmatrix} \begin{bmatrix}2\\1\end{bmatrix} \\ &= \begin{bmatrix}2\cdot 2 + 1\cdot 1\\1\cdot 2 + (-1)\cdot 1\end{bmatrix} \\ &= \begin{bmatrix}5\\1\end{bmatrix} = \mathbf{b} \end{aligned} \]

1.4 Pseudo-code for a 2x2 solver

algorithm solve_2x2_system(a11, a12, b1, a21, a22, b2)
    d <- a11*a22 - a12*a21
    if d = 0 then
        return "system has no unique solution"
    end_if
    x1 <- (b1*a22 - a12*b2)/d
    x2 <- (a11*b2 - b1*a21)/d
    return (x1, x2)
end

This structure prepares the next steps: computational methods and engineering applications involving larger linear models.