# Linear VS Affine

## Introduction

Sometimes, it is a little bit ambiguous between linear and affine and people often use these two terms interchangeably. However, strictly speaking, these two are different. Linear must be affine, but affine is not necessarily linear.

In this blog post, I would like to discuss the difference and relationship between linear and affine on functions, spaces, and transformations.

## Linear Function VS Affine Function

For a single-variable system, when we talked about linear functions, many people would describe it as

$$

y = ax + b

$$

But this is actually affine function. The linear function always goes through the origin $\mathbf{0}$ and it should be described as

$$

y = ax

$$

To determine a linear function, we would only need one point $(x_1, y_1)$ (because the other is always $(0, 0)$). But to determine an affine function, we would need two points $(x_1, y_1)$ and $(x_2, y_2)$.

## Linear Space VS Affine Space

Linear space is also called vector space. Its origin is specified as $\mathbf{0}$ and every vector in the vector space starts from the origin. Given a vector space $V$, suppose $\mathbf{v} \in V$ and $\mathbf{w} \in V$, we must have $a\mathbf{v} \in V$, $-\mathbf{v} \in V$, $\mathbf{v} + \mathbf{w} \in V$, $\mathbf{0} = \mathbf{v} - \mathbf{v} \in V$. A $n$-dimensional vector space can be described using a linear combination of $n$ linearly independent vectors. Equivalently, $n$ linearly independent vectors determines a $n$-dimensional vector space. For example, 1-dimensional vector space is a line, 2-dimension vector space is a plane.

Informally, affine space is a vector space whose origin is not specified. Given an affine space $A$, suppose $\mathbf{a} \in A$ and $\mathbf{b} \in A$, it’s not necessarily true that $a\mathbf{a} \in A$, $-\mathbf{a} \in A$, $\mathbf{a} + \mathbf{b} \in A$, $\mathbf{0} = \mathbf{a} - \mathbf{a} \in A$. Every affine space has an associated vector space $V$, such that the displacement vectors $\mathbf{v} = \mathbf{a} - \mathbf{b}$ between any two points $\mathbf{a} \in A$ and $\mathbf{b} \in A$ from the affine space $A$ are in the associated vector space $V$. The dimension of an affine space is determined by the dimension of its associated vector space.

Formally, an affine space is a set $A$ together with a vector space $V$, and a transitive and free action of the additive group of $V$ on the set $V$. This definition creates a mapping from $A$ and $V$ to $A$, i.e.,

$$

A \times V \rightarrow A

$$

$$

(a, v) \mapsto a + v

$$

where $a \in A$, $v \in V$, and $\mapsto$ is actually a bijection.

The following is an example of an affine space.

$\mathbf{0} \in P_1$ but $P_1$ is not necessarily $z = 0$. $P_1$ and $P_2$ are parallel with each other. Based on the formal definition of affine space, we could see that $P2$ is an affine space and $P_1$ is the vector space associated with the affine space $P_2$. Specifically, $\mathbf{a} \in P_2$ and $\mathbf{b} \in P_2$, $\mathbf{a} + \mathbf{b} \notin P_2$, $\mathbf{0} \notin P_2$, $\mathbf{a} - \mathbf{b} \in P_1$.

Suppose $P_1: \{a \mathbf{v} + b \mathbf{w}\}$ where $\mathbf{v} \in \mathbb{R}^3$, $\mathbf{w} \in \mathbb{R}^3$, and $\mathbf{v} \neq k\mathbf{w}$. Because $P_1$ has two linearly independent points, $P_1$ is a 2-dimensional vector space. In addition, $P_2: \{a \mathbf{v} + b \mathbf{w} + \mathbf{u} \}$ where $\mathbf{u}$ is a translation vector. Given any two points in the affine space $P_2$, $\mathbf{a} = a_1 \mathbf{v} + b_1 \mathbf{w} + \mathbf{u}$, $\mathbf{b} = a_2 \mathbf{v} + b_2 \mathbf{w} + \mathbf{u}$, we have $\mathbf{a} - \mathbf{b} = (a_1 - a_2) \mathbf{v} + (b_1 - b_2) \mathbf{w}$ and it is in the associated vector space $P_1$. Because the associated vector space $P_1$ of the affine space $P_2$ is 2-dimensional, by definition, the affine space $P_2$ is 2-dimensional.

The next question is, how many affinely independent points do we need to determine a $n$-dimensional affine space? Notice in the example above, two points $\mathbf{a}$ and $\mathbf{b}$ are insufficient to determine the 2-dimensional affine space. If we have a third point $\mathbf{c}$, and $\mathbf{a} - \mathbf{c} \in P_1$, $\mathbf{b} - \mathbf{c} \in P_1$, $\mathbf{a} - \mathbf{c}$ and $\mathbf{b} - \mathbf{c}$ are linearly independent, then we can determine the 2-dimensional affine space. Therefore, to determine a $n$-dimensional affine space, we would need $n + 1$ affinely independent points. Here, a set of $n + 1$ affinely independent points is an affine basis of the affine space. Notice that here we have not defined what affine basis is. But we already have a good gut feeling that $\{\mathbf{x}_0, \cdots, \mathbf{x}_n\}$ is an affine basis of an affine space if and only if $\{\mathbf{x}_1 - \mathbf{x}_0, \cdots, \mathbf{x}_n - \mathbf{x}_0\}$ is a linear basis of the associated vector space.

The vector space is also an affine space. The $n$-dimensional vector space has a basis consisting of $n$ linearly independent points $\{\mathbf{x}_1, \cdots, \mathbf{x}_n\}$ and has $n + 1$ affinely independent points $\{\mathbf{0}, \mathbf{x}_1, \cdots, \mathbf{x}_n\}$. Notice that the origin $\mathbf{0}$ must be in the affine basis for an affine space that is also a vector space.

## Linear Transformation VS Affine Transformation

The linear function and affine function are just special cases of the linear transformation and affine transformation, respectively. Suppose we have a point $\mathbf{x} \in \mathbb{R}^{n}$, and a square matrix $\mathbf{M} \in \mathbb{R}^{n \times n}$, the linear transformation of $\mathbf{x}$ using $\mathbf{M}$ can be described as

$$

\mathbf{y} = \mathbf{M} \mathbf{x}

$$

Suppose we have another translation vector $\mathbf{b} \in \mathbb{R}^{n}$, the affine transformation of $\mathbf{x}$ using $\mathbf{M}$ and $\mathbf{b}$ can be described as

$$

\mathbf{y} = \mathbf{M} \mathbf{x} + \mathbf{b}

$$

An affine transformation in a $n$-dimensional affine space is actually equivalent to a linear transformation in a $n + 1$-dimensional space. To see this, recall the augmented coordinates that I mentioned in my previous blog post “2D Line Mathematics Using Homogeneous Coordinates”, we will use the augmented coordinates for $\mathbf{x}$ and $\mathbf{y}$. The affine transformation described above could also be described using augmented coordinates.

$$

\begin{align}

\left [

\begin{array}{c|c}

\mathbf{y} \\

1 \\

\end{array}

\right ]

&=

\left [

\begin{array}{c|c}

\mathbf{M} & \mathbf{b} \\

\hline

\mathbf{0} & 1 \\

\end{array}

\right ]

\left [

\begin{array}{c|c}

\mathbf{x} \\

1 \\

\end{array}

\right ] \\

&=

\left [

\begin{array}{c|c}

\mathbf{M} \mathbf{x} + \mathbf{b} \\

1 \\

\end{array}

\right ]

\end{align}

$$

Therefore, an affine transformation in a $n$-dimensional affine space is actually equivalent to a linear transformation in a $n + 1$-dimensional space.

## References

Linear VS Affine