\section{Matrices}

\definition{}
A \textit{matrix} is a two-dimensional array of numbers: \\
$$
A =
\begin{bmatrix}
	1 & 2 & 3 \\
	4 & 5 & 6
\end{bmatrix}
$$
The above matrix has two rows and three columns. It is thus a $2 \times 3$ matrix.

\definition{}
We can define the product of a matrix $A$ and a vector $v$:

$$
Av =
\begin{bmatrix}
	1 & 2 & 3 \\
	4 & 5 & 6
\end{bmatrix}
\begin{bmatrix}
	a \\ b \\ c
\end{bmatrix}
=
\begin{bmatrix}
	1a + 2b + 3c \\
	4a + 5b + 6c
\end{bmatrix}
$$
Each element of the resulting $2 \times 1$ matrix is the dot product of a row of $A$ with $v$:

$$
Av =
\begin{bmatrix}
	\text{---} a_1 \text{---} \\
	\text{---} a_2 \text{---}
\end{bmatrix}
\begin{bmatrix}
	| \\
	v \\
	| \\
\end{bmatrix}
=
\begin{bmatrix}
	r_1v \\
	r_2v
\end{bmatrix}
$$

Naturally, a vector can only be multiplied by a matrix if the number of rows in the vector equals the number of columns in the matrix.


\problem{}
Say you multiply a size-$m$ vector by an $m \times n$ matrix. What is the size of your result?

\vfill


\problem{}
Compute the following:

$$
\begin{bmatrix}
	1 & 2 \\
	3 & 4 \\
	5 & 6
\end{bmatrix}
\begin{bmatrix}
	5 \\ 3
\end{bmatrix}
$$

\vfill
\pagebreak


\generic{Remark:}
It is a bit more interesting to think of matrix-vector multiplication in the following way: \\

\begin{minipage}[t]{0.48\textwidth}\vspace{0pt}
	\begin{center}
		The problem:
		\vspace{2mm}

		$$
		\begin{bmatrix}
			1 & 2 \\
			3 & 4 \\
			5 & 6
		\end{bmatrix}
		\begin{bmatrix}
			5 \\ 3
		\end{bmatrix}
		=
		\begin{bmatrix}
			11 \\ 27 \\ 43
		\end{bmatrix}
		$$
	\end{center}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.48\textwidth}\vspace{0pt}
	\begin{center}
	Top-input, right-output:
	\vspace{2mm}

	\begin{tikzpicture}[>=stealth,thick,baseline]
		\matrix [
			matrix of math nodes,
			left delimiter={[},
			right delimiter={]}
		] (A) {
			1 & 2 \\
			3 & 4 \\
			5 & 6 \\
		};

		\node[
			fit=(A-1-1)(A-1-1),
			inner xsep=0mm,inner ysep=3mm,
			label=above:5
		] (L) {};
		\draw[->, gray] (L.north) -- ([yshift=0mm]A-1-1.north);

		\node[
			fit=(A-1-2)(A-1-2),
			inner xsep=0mm,inner ysep=3mm,
			label=above:3
		] (R) {};
		\draw[->, gray] (R.north) -- ([yshift=0mm]A-1-2.north);


		\node[
			fit=(A-1-2)(A-1-2),
			inner xsep=8mm,inner ysep=0mm,
			label=right:{$5 + 6 = 11$}
		](Y) {};
		\draw[->, gray] ([xshift=3mm]A-1-2.east) -- (Y);

		\node[
			fit=(A-2-2)(A-2-2),
			inner xsep=8mm,inner ysep=0mm,
			label=right:{$15 + 12 = 27$}
		](H) {};
		\draw[->, gray] ([xshift=3mm]A-2-2.east) -- (H);

		\node[
			fit=(A-3-2)(A-3-2),
			inner xsep=8mm,inner ysep=0mm,
			label=right:{$25 + 18 = 43$}
		](N) {};
		\draw[->, gray] ([xshift=3mm]A-3-2.east) -- (N);
	\end{tikzpicture}
	\end{center}
\end{minipage}%

\vspace{2mm}

This is only a model for intuition, though. \\
Make sure you understand the dot product definition on the previous page.

\vspace{5mm}

\theorem{}<thebigtheorem>
Any linear map $T: \mathbb{R}^n \to \mathbb{R}^m$ can be written as an $n \times m$ matrix. \\
Conversely, every $n \times m$ matrix represents a liner map $T: \mathbb{R}^n \to \mathbb{R}^m$ \\

\vspace{2mm}

In other words, \textbf{matrices are linear transformations}.
\problem{}<prooffwd>
Show that the transformation $T: \mathbb{R}^n \to \mathbb{R}^m$ defined by $T(v) = Av$ is linear. \\
\hint{What is $A$? What is $v$? What are their sizes?}

\vfill

\problem{}<proofback>
Show that any linear transformation $T: \mathbb{R}^n \to \mathbb{R}^m$ can be written as $T(v) = Av$.

\vfill


\problem{}
Consider the transformation $D: \mathbb{P}^3 \to \mathbb{P}^2$ defined by $D(p) = \frac{d}{dx}p$. \\
Find a matrix that corresponds to $D$. \\
\hint{$\mathbb{P}^3$ and $\mathbb{R}^4$ are isomorphic. How so?}


\vfill
\pagebreak


\problem{}
Does \ref{thebigtheorem} hold in arbitrary vector spaces? \\
Repeat \ref{prooffwd} and \ref{proofback} using only axioms, without assuming that we're working in $\mathbb{R}^n$.

\vfill
\pagebreak