A linear transformation is any transformation $f:U\to V$ between vector spaces over $\mathbb F$ for which
- $f(x+y)=f(x)+f(y)$
- $f(\alpha x) = \alpha f(x)$
for all $x,y\in U$ and all $\alpha\in\mathbb F$.
An affine transformation is any transformation $f:U\to V$ for which, if $\sum_i\lambda_i = 1$, $$f(\sum_i \lambda_i x_i) = \sum_i \lambda_i f(x_i)$$
for all sets of vectors $x_i\in U$.
In effect, what these two definitions mean is:
- All linear transformations are affine transformations.
- Not all affine transformations are linear transformations.
- It can be shown that any affine transformation $A:U\to V$ can be written as $A(x) = L(x) + v_0$, where $v_0$ is some vector from $V$ and $L:U\to V$ is a linear transformation.
Take an example where $U=V=\mathbb R^2$. Then $$f:(x,y) \mapsto(-2x+y, 3x+8y)$$ is a linear transformation, since
$$f((x_1,y_1)+(x_2, y_2)) = (-2(x_1+x_2) + y_1+y_2, 3(x_1+x_2) + 8(y_1+y_2)) = \\
= (-2x_1 + y_1, 3x_1 + 8y_1) + (-2x_2 + y_2, 3x_2 + 8y_2) = f((x_1,y_1)+f((x_2, y_2))$$
However, $$g:(x,y)\mapsto (-2x+y+5, 3x+8y-2)$$
is not a linear function (you can immediatelly see this since $g((0,0)) \neq (0,0)$, while linear functions always map $0$ to $0$).
Both $g$ and $f$ are (you can check) affine functions.