A map $f:{\mathbf{R}}^{n}\to {\mathbf{R}}^{m}$ is linear if there exists an $m$ by$n$ matrix $A$ such that $f(v)=Av$ for all $v\in {\mathbf{R}}^{n}$ .
38. Linear maps
38. Linear maps
Two definitions of linearity
At the outset of this course, we talked about the geometric transformations coming from matrices (rotations, reflections, shears etc). These geometric transformations have a name: they are called linear maps. In this video we'll give two definitions of linear maps and show they're equivalent. The first definition encapsulates how we've been dealing with linear maps so far:
However, some linear maps are more natural to describe in another way, without giving the matrix $A$ .
Fix $n$ . Consider the space of polynomials $P(x)$ of degree at most $n$ . Differentiation gives a map $\frac{d}{dx}:P\mapsto dP/dx$ from this space to itself. This map is linear. To understand why, we need to understand polynomials as vectors. We encode a polynomial $$P(x)={a}_{n}{x}^{n}+\mathrm{\cdots}+{a}_{1}x+{a}_{0}$$ as its vector of coefficients $\left(\begin{array}{c}\hfill {a}_{0}\hfill \\ \hfill {a}_{1}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {a}_{n}\hfill \end{array}\right)$ . Then $$\frac{dP}{dx}=n{a}_{n}{x}^{n1}+\mathrm{\cdots}+2{a}_{2}x+{a}_{1},$$ which corresponds to the vector of coefficients $\left(\begin{array}{c}\hfill {a}_{1}\hfill \\ \hfill 2{a}_{2}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill n{a}_{n}\hfill \\ \hfill 0\hfill \end{array}\right)$ . This is the same as $$\left(\begin{array}{cccccc}\hfill 0\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill \mathrm{\cdots}\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 2\hfill & \hfill 0\hfill & \hfill \mathrm{\cdots}\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 3\hfill & \hfill 0\hfill & \hfill \mathrm{\vdots}\hfill \\ \hfill \mathrm{\vdots}\hfill & \hfill \mathrm{\ddots}\hfill & \hfill \mathrm{\ddots}\hfill & \hfill \mathrm{\ddots}\hfill & \hfill \mathrm{\ddots}\hfill & \hfill \mathrm{\vdots}\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \mathrm{\cdots}\hfill & \hfill 0\hfill & \hfill n\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \mathrm{\cdots}\hfill & \hfill 0\hfill & \hfill 0\hfill \end{array}\right)\left(\begin{array}{c}\hfill {a}_{0}\hfill \\ \hfill {a}_{1}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {a}_{n}\hfill \end{array}\right)$$ so differentiation is linear (given by a matrix). In other words, if ${v}_{P}$ is the vector of coefficients of the polynomial $P$ then $D{v}_{P}={v}_{dP/dx}$ , where $D$ is this matrix.
This way of encoding polynomials as vectors is a bit artificial. For example, I could have chosen to write the vector with ${a}_{n}$ at the top and ${a}_{0}$ at the bottom, and the matrix $D$ would have ended up looking quite different. The fact that differentiation of polynomials is a linear map is an intrinsic fact about differentiation, and our proof above obscures that. So here's an equivalent definition of linearity which is more intrinsic.
A map $f$ is linear if:

$f(v+w)=f(v)+f(w)$ for all $v,w$

$f(\lambda v)=\lambda f(v)$ for all $v$ and for all $\lambda \in \mathbf{R}$ .
I haven't specified the domain and target of $f$ because I want to be intentionally vague: this definition makes sense whenever the domain and target of $f$ admit operations of addition and rescaling (e.g. spaces of polynomials or functions as well as just ${\mathbf{R}}^{n}$ ). In the final video of the course, we'll see that the natural setting for this definition is the setting of vector spaces.
Differentiation of polynomials is linear because $$\frac{d}{dx}(P+Q)=\frac{dP}{dx}+\frac{dQ}{dx}$$ and $$\frac{d(\lambda P)}{dx}=\lambda \frac{dP}{dx}$$ for any constant $\lambda $ and polynomials $P(x),Q(x)$ .
The function $f:\mathbf{R}\to \mathbf{R}$ which converts metres to feet is linear. Since 1 metre is $\approx 3.281$ feet, $f(x)=3.281x$ . If you double the number of metres, you double the number of feet. If you take two distances $x$ metres and $y$ metres you can add them and then convert to feet ($f(x+y)$ ) or you can convert and then add ($f(x)+f(y)$ ) and you get the same answer. So $f$ is linear.
The function $f:\mathbf{R}\to \mathbf{R}$ which converts Celsius to Kelvin is not linear. Recall that $f(0)\approx 273$ . Any linear map satisfies $f(0)=0$ , because $f(0)=f(00)=0f(0)=0$ (some of those $0$ s are numbers, some are vectors!).
I'm told the way they used to mark exams in Oxford was to take the marks from each question, square them and add them up. For example, if there were two questions and you got marks $x$ and $y$ then your final score would be ${x}^{2}+{y}^{2}$ . This rewards those who do very well on a couple of questions (instead of scattergunning a little bit of knowledge over all questions). This function $f(x,y)={x}^{2}+{y}^{2}$ is not a linear map! For example, if you score $1$ and $0$ then you get $1$ in total, but if you double your score for $x$ then you quadruple your total. Sadly for those taking the exam, $f(0,0)=0$ .
Equivalence
These two definitions of linearity are equivalent. In other words, the conditions

$f(v+w)=f(v)+f(w)$ and $f(\lambda v)=\lambda f(v)$
imply there exists a matrix $A$ such that $f(v)=Av$ , and any map of this form satisfies these conditions.
If $f(v)=Av$ for some matrix $A$ then $$f(v+w)=A(v+w)=Av+Aw=f(v)+f(w)$$ and $$f(\lambda v)=A(\lambda v)=\lambda Av=\lambda f(v).$$
Conversely, consider the basis vectors $${e}_{1}=\left(\begin{array}{c}\hfill 1\hfill \\ \hfill 0\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill 0\hfill \end{array}\right),{e}_{2}=\left(\begin{array}{c}\hfill 0\hfill \\ \hfill 1\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill 0\hfill \end{array}\right),\mathrm{\cdots},{e}_{n}=\left(\begin{array}{c}\hfill 0\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill 0\hfill \\ \hfill 1\hfill \end{array}\right).$$ Let $A$ be the matrix whose columns are $f({e}_{1}),f({e}_{2}),\mathrm{\dots},f({e}_{n})$ .
Then $$f(v)=f\left(\begin{array}{c}\hfill {v}_{1}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {v}_{n}\hfill \end{array}\right)=f({v}_{1}{e}_{1}+\mathrm{\cdots}+{v}_{n}{e}_{n})={v}_{1}f({e}_{1})+\mathrm{\cdots}+{v}_{n}f({e}_{n}).$$ Since $f({e}_{k})$ is the $k$ th column of $A$ , it agrees with $A{e}_{k}$ (also the $k$ th column of $A$ ). Therefore $$f(v)={v}_{1}A{e}_{1}+\mathrm{\cdots}+{v}_{n}A{e}_{n}=A({v}_{1}{e}_{1}+\mathrm{\cdots}+{v}_{n}{e}_{n})=Av,$$ which shows that $f$ is linear in the sense that it has the form $f(v)=Av$ for some matrix $A$ .