Continue **reading** Section 1.2 for next class, as well as the code vectors
part of Section 1.4. (The rest of 1.4 will not be covered.)

Work through recommended homework questions.

**Tutorials** start January 15, and include a **quiz** covering until
Monday's lecture. More details on Monday.

**Office hour:** Monday, 1:30-2:30, MC103B.

**Help Centers:** Monday-Friday 2:30-6:30 in MC 106, but not
starting until Monday, January 20.

**Lecture notes** (this page) available from course web page by
clicking on the link.
Answers to lots of administrative questions are available on the course web page as well.

**Definition:** A vector $\vv$ is a **linear combination**
of vectors $\vv_1, \vv_2, \ldots, \vv_k$ if there exist scalars
$c_1, c_2, \ldots, c_k$ (called coefficients) such that
$$
\vv = c_1 \vv_1 + \cdots + c_k \vv_k .
$$
We also call the coefficients **coordinates** when we are
thinking of the vectors $\vv_1, \vv_2, \ldots, \vv_k$ as defining
a new coordinate system.

**Vectors modulo $m$:**

$\Z_m = \{0, 1, \ldots, m-1\}$ with addition and multiplication taken modulo $m$. That means that the answer is the remainder after division by $m$.

For example, in $\Z_{10}$, $\quad 8 \cdot 8 = 64 = 4 \pmod{10}$.

$\Z_m^n$ is the set of vectors with $n$ components each of which is in $\Z_m$.

To find solutions to an equation such as $$ 6 x = 6 \pmod{8} $$ you can simply try all possible values of $x$. In this case, $1$ and $5$ both work, and no other value works.

Note that you can not in general **divide** in $\Z_m$, only
add, subtract and multiply.

Most of this course will concern vectors with real components. Vectors in $\Z_m^n$ will just be used to study code vectors.

**Definition:** The **dot product** of vectors $\vu$ and $\vv$
in $\R^n$ is the real number defined by
$$
\vu \cdot \vv := u_1 v_1 + \cdots + u_n v_n .
$$
Since $\vu \cdot \vv$ is a *scalar*, the dot product is sometimes
called the **scalar product**, not to be confused with
*scalar multiplication* $c \vv$.

The dot product will be used to define length, distance and angles in $\R^n$.

**Example:** For $\vu = [1, 0, 3]$ and $\vv = [2, 5, -1]$, we have
$$
\vu \cdot \vv = 1 \cdot 2 + 0 \cdot 5 + 3 \cdot (-1) = 2 + 0 - 3 = -1 .
$$

We can also take the dot product of vectors in $\Z_m^n$, by reducing the answer modulo $m$.

**Example:** For $\vu = [1, 2, 3]$ and $\vv = [2, 3, 4]$ in $\Z_5^3$, we have
$$
\vu \cdot \vv = 1 \cdot 2 + 2 \cdot 3 + 3 \cdot 4 = 2 + 6 + 12 = 20 = 0 \pmod{5}.
$$
In $\Z_6^3$, the answer would be $\query{2.}$

**Theorem 1.2:** For vectors $\vu, \vv, \vw$ in $\R^n$ and $c$ in $\R$:

(a) $\ \vu \cdot \vv = \vv \cdot \vu$

(b) $\ \vu \cdot (\vv + \vw) = \vu \cdot \vv + \vu \cdot \vw$

(c) $\ (c \vu) \cdot \vv = c(\vu \cdot \vv) = \vu \cdot (c \vv)$

(d) $\ \vu \cdot \vu \geq 0$

(e) $\ \vu \cdot \vu = 0$ __if and only if__ $\vu = \vec 0$

Again, very similar to how multiplication and addition of numbers works.

Explain (b) and (d) on board. (a) and (c) are explained in text.

The length of a vector $\vv = [v_1, v_2]$ in $\R^2$ is $\sqrt{v_1^2 + v_2^2}$, using the Pythagorean theorem. (Sketch.) Notice that this is equal to $\sqrt{\vv \cdot \vv}$. This motivates the following definition:

**Definition:** The **length** or **norm** of a vector
$\vv$ in $\R^n$ is the scalar $\|\vv\|$ defined by
$$
\|\vv\| := \sqrt{\vv \cdot \vv} = \sqrt{v_1^2 + \cdots + v_n^2} .
$$

**Example:** The length of $[1, 2, 3, 4]$ is $\sqrt{1^2 + 2^2 + 3^2
+ 4^2} = \sqrt{30}$.

**Note:** $\|c \vv\| = |c| \|\vv\|$. (Explain on board.)

**Definition:** A vector of length 1 is called a **unit**
vector.

The unit vectors in $\R^2$ form a circle. (Sketch.)
Examples are $[ 1, 0 ]$, $[0, 1]$, $[\frac{-1}{\sqrt{2}},
\frac{1}{\sqrt{2}}]$, and lots more.
The first two are denoted $\ve_1$ and $\ve_2$ and are called
the **standard unit vectors** in $\R^2$.

The unit vectors in $\R^3$ form a sphere.
The **standard unit vectors** in $\R^3$ are
$\ve_1 = [1, 0, 0]$, $\ve_2 = [0, 1, 0]$ and $\ve_3 = [0, 0, 1]$.

More generally, the **standard unit vectors** in $\R^n$ are
$\ve_1, \ldots, \ve_n$, where $\ve_i$ has a $1$ as its $i$th component
and a $0$ for all other components.

Given any vector $\vv$, there is a unit vector in the same direction
as $\vv$, namely
$$
\frac{1}{\|\vv\|} \svv
$$
This has length $1$ using the previous Note. (Sketch and example on board.)
This is called **normalizing** a vector.

**Theorem 1.5: The Triangle Inequality:**
For all $\vu$ and $\vv$ in $\R^n$,
$$
\| \vu + \vv \| \leq \| \vu \| + \| \vv \| .
$$

**On board:** Example in $\R^2$: $\vu = [1,0]$ and $\vv = [3,4]$.

Theorem 1.5 is geometrically plausible, at least in $\R^2$ and $\R^3$. The book proves that it is true in $\R^n$ using Theorem 1.4, which we will discuss below.

Thinking of vectors $\vu$ and $\vv$ as starting from the origin,
we define the **distance** between them by the formula
$$
d(\vu, \vv) := \| \vu - \vv \| = \sqrt{(u_1 - v_1)^2 + \cdots + (u_n - v_n)^2},
$$
generalizing the formula for the distance between points in the plane.

**Example:** The distance between $\vu = [10, 10, 10, 10]$ and $\vv = [11, 11, 11, 11]$
is $$\sqrt{(-1)^2 + (-1)^2 + (-1)^2 + (-1)^2} = \sqrt{4} = 2 .$$

In particular, $|\vu \cdot \vv| \leq \| \vu \| \, \| \vv \|$, since $|\cos \theta| \leq 1$.

This holds in $\R^n$ as well, but we won't give the proof:

**Theorem 1.4: The Cauchy-Schwarz Inequality:**
For all $\vu$ and $\vv$ in $\R^n$,
$$
| \vu \cdot \vv | \leq \| \vu \| \, \| \vv \| .
$$

We can therefore use the dot product to *define* the **angle** between
two vectors $\vu$ and $\vv$ in $\R^n$ by the formula
$$
\cos \theta := \frac{\vu \cdot \vv}{\| \vu \| \, \| \vv \|},
\quad \text{i.e.,} \quad \theta := \arccos \left( \frac{\vu \cdot \vv}{\| \vu \| \, \| \vv \|} \right),
$$
where we choose $0 \leq \theta \leq 180^\circ$.
This makes sense because the fraction is between -1 and 1.

To help remember the formula for $\cos \theta$, note that the denominator normalizes the two vectors to be unit vectors.

**On board**: Angle between $\vu = [1, 2, 1, 1, 1]$ and $\vv = [0, 3, 0, 0, 0]$.

An applet illustrating the dot product. If it doesn't work, try the java version.

For a random example, you'll need a calculator, but for hand calculations you can remember these cosines: $$ \small\kern-8ex \begin{aligned} \cos 0^\circ &= \frac{\sqrt{4}}{2} = 1, & \cos 30^\circ &= \frac{\sqrt{3}}{2} , & \cos 45^\circ &= \frac{\sqrt{2}}{2} = \frac{1}{\sqrt{2}}, \\ \cos 60^\circ &= \frac{\sqrt{1}}{2} = \frac{1}{2}, & \cos 90^\circ &= \frac{\sqrt{0}}{2} = 0 , \end{aligned} $$ using the usual triangles.