**Read** Section 1.3 for next class. Work through recommended
homework questions.

Tutorials start **next week**, and include a **quiz** covering
Sections 1.1, 1.2 and the code vectors part of 1.4.
It does not cover the Exploration after Section 1.2.

Questions are *similar* to homework questions, but may be slightly different.
There will be **two true/false questions**, for which you must explain your answers.

The quizzes last 20 minutes, and are at the end of the tutorial, so
you have time for questions at the beginning.
You must write in the tutorial you are **registered** in.
Different sections have different quizzes, but it is still considered
an academic offense to share information about quizzes.

**No calculators or other aids** are permitted on quizzes or exams.

**Today** is the last day you can **switch tutorial sections**.
This must be done via paper add/drop in MC104, 9:30-3:30.
No line ups! Updated counts:

003 W 9:30AM KB-K103 40 ! 009 W 9:30AM UCC-65 17 * 008 W 11:30AM UCC-60 40 ! 006 W 3:30PM UC-202 35 005 Th 11:30AM SSC-3010 39 ! 007 Th 12:30PM MC-17 35 004 Th 2:30PM UC-202 34

**Office hours:** Monday, 3:00-3:30 and Wednesday, 11:30-noon, MC103B.

**Help Centers:** Monday-Friday 2:30-6:30 in MC 106 starting Wednesday,
September 17.

Lecture notes (this page) available from course web page.

A copy of the Solutions Manual has been put on reserve in Taylor Library.

The midterm is in 6 weeks!

**Definition:** The **dot product** or **scalar 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 .
$$

This has familiar properties; see Theorem 1.2.

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

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

We define the **distance** between vectors $\vu$ and $\vv$ by the formula
$$
d(\vu, \vv) := \| \vu - \vv \| = \sqrt{(u_1 - v_1)^2 + \cdots + (u_n - v_n)^2}.
$$

**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. The formula can also be written $$ \vu \cdot \vv = \| \vu \| \, \| \vv \| \, \cos \theta . $$

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.

Easy: $\theta = 90^\circ$ is the only angle for which $\cos \theta = 0$.

So $\vu$ and $\vv$ are**orthogonal** if and only if $\vu \cdot \vv = 0$.

So $\vu$ and $\vv$ are

**Example:** If $\vu = [1, 2, 3]$ and $\vv = [1, 1, -1]$ in $\R^3$,
then $\vu \cdot \vv = 1 \cdot 1 + 2 \cdot 1 + 3 \cdot (-1) = 1 + 2 -
3 = 0$, so $\vu$ and $\vv$ are orthogonal.

Also, $\vu = [1, 2, 3]$ and $\vv = [1, 1, 1]$ in $\Z_3^3$ are orthogonal, since $\vu \cdot \vv = 1 + 2 + 3 = 6 = 0 \pmod{3}$.

An applet illustrating the dot product. (Another one: javascript, and java.)

**Pythagorean theorem in $\R^n$:** If $\vu$ and $\vv$ are orthogonal,
then
$$
\| \vu + \vv \|^2 = \| \vu \|^2 + \| \vv \|^2 .
$$

Explain on board, using Theorem 1.2.

$$
\textrm{proj}_{\vu}(\vv) = \left( \frac{\vu \cdot \vv}{\vu \cdot \vu} \right) \vu .
$$
Here $\vu$ must not be $\vec 0$, but $\vv$ can be any vector.
To help remember the formula, note that the denominator ensures that
the answer does not depend on the length of $\vu$.

This applet is useful for understanding projections as well. Java version.

**Example:** If $\vu = [-1, 1, 0]$ and $\vv = [1,2,3]$ then
$$
\kern-4ex
\begin{aligned}
\proj_\vu(\vv) = \frac{\vu \cdot \vv}{\vu \cdot \vu} \vu
&= \frac{-1+2+0}{1+1+0} [-1, 1, 0] \\
&= \frac{1}{2} [-1,1,0]
= [-\!\frac{1}{2}, \frac{1}{2}, 0]
\end{aligned}
$$

**True/false:**
If $\vu$, $\vv$ and $\vw$ are vectors in $\R^n$ such that
$\vu \cdot \vv = \vu \cdot \vw$ and $\vu \neq \vec 0$,
then $\vv = \vw$.

**True/false:**
If $\vu$ is orthogonal to both $\vv$ and $\vw$, then
$\vu$ is orthogonal to $2 \vv + 3 \vw$.

You only answer **true** if a statement is *always* true.
You justify this answer by giving a general explanation of why it is always
true, not just an example where it happens to be true.

You answer **false** if a statement can in *some case* be false.
You justify this answer by giving an explicit example where the
statement is false.

**Question:**
Suppose I tell you that $\vu \cdot \vv = 1/2$ and
$\vu \cdot \vw = -1$. What is $\vu \cdot (2 \vv + 3 \vw)$?

**Question:**
Does $\proj_{\vu}(\vv)$ always point in the
same direction as $\vu$?

**Example 1.37:** Suppose we want to send the four commands "forward", "back",
"left" and "right" as a sequence of 0s and 1s. We could use the following
code:
$$
\small\kern-8ex
\textrm{forward} = [0,0], \quad
\textrm{back} = [0,1], \quad
\textrm{left} = [1,0], \quad
\textrm{right} = [1,1].
$$
But if there is an error in our transmission, the Mars rover will get the
wrong message and will drive off of a cliff, wasting billions of dollars
of taxpayer money (but making for some good NASA jokes).

Here's a more clever code:
$$
\small\kern-8ex
\textrm{forward} = [0,0,0], \quad
\textrm{back} = [0,1,1], \quad
\textrm{left} = [1,0,1], \quad
\textrm{right} = [1,1,0].
$$
If any single *bit* (binary digit, a 0 or a 1) is flipped during
transmission, the Mars rover will notice the error, since all of the
**code vectors** have an **even** number of 1s. It could then
ask for retransmission of the command.

This is called an **error-detecting code**.
Note that it is formed by adding a bit to the end of each of the original
code vectors so that the total number of 1s is even.

In vector notation, we replace a vector $\vb = [v_1, v_2, \ldots, v_n]$ with the vector $\vv = [v_1, v_2, \ldots, v_n, d]$ such that $\vec 1 \cdot \vv = 0 \pmod{2}$, where $\vec 1 = [1, 1, \ldots, 1]$.

Exactly the same idea works for vectors in $\Z_3^n$; see Example 1.39 in the text.

**Note:** One problem with the above scheme is that **transposition** errors
are not detected: if we want to send $[0, 1, 1]$ but the first two
bits are exchanged, the rover receives $[1, 0, 1]$, which is also a
valid command. We'll see codes that can detect transpositions.