# 1.2 Lengths and Dot Products

## Abstract

After linear combination, today we are going to meet another simple but important concept — Dot Products. And dot products can produce some other interesting concepts or so.

**keywords**: *Dot Products, Lengths, Perpendicular, Unit Vectors*

## The Map of Concepts

# Lengths and Dot Products

## Dot Products

We have learned how to add two or more vectors up and how to do multiply a vector by a number, the processes are:

Addition

$$

\vec{v}+\vec{w}=

\begin{bmatrix}v_1\newline v_2\end{bmatrix}+

\begin{bmatrix}w_1\newline w_2\end{bmatrix}=

\begin{bmatrix}v_1+w_1\newline v_2+w_2\end{bmatrix}

\tag{1.2.1}

$$Scalar Multiplication(By a number)

$$

c\vec{v}=c\begin{bmatrix}v_1\newline v_2\end{bmatrix}=\begin{bmatrix}cv_1\newline cv_2\end{bmatrix}\tag{1.2.2}

$$Linear Combination

$$

c\vec{v}+d\vec{w}=

c\begin{bmatrix}v_1\newline v_2\end{bmatrix}+

d\begin{bmatrix}w_1\newline w_2\end{bmatrix}=

\begin{bmatrix}cv_1+dw_1\newline cv_2+dw_2\end{bmatrix}\tag{1.2.3}

$$

Then a new idea come to us from the scalar multiplication,that is we have know about how to multiply a vector by a number, but how about multiply a vector by a vector. We do not have any ideas so far, and what we cencern is the result of this new multiplication. It would be a vector or a number is also alternative.

Now, let’s go into the new concept – “dot products”, and it is designed like that, if vector $\vec{v}=\begin{bmatrix}v_1\newline v_2\end{bmatrix}$ is dot multiplyed by $\vec{w}=\begin{bmatrix}w_1\newline w_2\end{bmatrix}$, the first step is producting the components of each vector sparately, then we get $v_1w_1$ and $v_2w_2$, and after that, add this two numbers together to get the final result $v_1w_1+v_2w_2$ .

DEFINITION The dot product or inner product of $\vec{v}={v_1,v_2}$ and $\vec{w}={w_1,w_2}$ is the number $\vec{v}\cdot\vec{w}$:

$$

\vec{v}\cdot\vec{w}=v_1w_1+v_2w_2\tag{1.2.4}

$$

Let’s look at a naive example, multiply $\vec{v}={4,2}$ by $\vec{w}={-1,2}$:

$$

\vec{v}\cdot\vec{w}=v_1w_1+v_2w_2=4\times(-1)+2\times 2=0\tag{1.2.5}

$$

**DO REMEBER THAT DOT PRODUCT HAS ONLY ONE NOTATION – A POINT LIES BETWEEN TWO VECTORS**

### A Special Number 0

In mathematics $0$ (here we talk about the number 0, not the zero vector) is always special number. In dot products, it means these two vectors are **perpendicular**, and in other words, we know that vector has a direction, and **perpendicular** means the angle between these two vectors are $90^\circ$ . We can draw a picture to show the angle between these two 2-dimensional vectors in the way we talked last post(click and go there). And it is like this:

### More about Dot Products

However, we go on talk something about dot products. The order of vectors will not change the result of dot products:

$$

\vec{w}\cdot\vec{v}=w_1v_1+w_2v_2=v_1w_1+v_2w_2=\vec{v}\cdot\vec{w}\tag{1.2.6}

$$

And here we talk about something that is in our daily life, that can be described with dot product. Some of us may know the concept of “moments”, it has different meaning in different subjects. If we are dealing with the problem describe below, of cource this may happen in many engineering or science projects, we can use dot products and “moments”:

Put a weight of $w_1=4$ at the point $x_1=-1$ (left of zero) and a weight of $w_2=2$ at the point $x_2=2$（right of zero）the x-axis will balance, because $w_1\cdot x_1+w_2\cdot x_2=0$ , perfect balance.

The moment here is $w_1x_1$ or $w_2x_2$.

Three deminsional vectors or more than three deminsional vectors, $\vec{v}=\begin{bmatrix}v_1\newline\vdots\newline v_n\end{bmatrix}$ and $\vec{w}=\begin{bmatrix}w_1\newline\vdots\newline w_n\end{bmatrix}$, can also do dot products with the same idea:

$$

\vec{v}\cdot\vec{w}=\sum_{i=0}^{n}v_iw_i\tag{1.2.7}

$$

As (1.2.7) said, the result of dot product will always be a number.

## Lengths

According the way we created zero vector last post, we are going to try to dot products the two same vectors, such as:

$$

\vec{v}\cdot\vec{v}=v_1^2+v_2^2\tag{1.2.8}

$$

And this is what is called “the square of length of the vector $\vec{v}$” and it is written as :

$$

||\vec{v}||^2=\vec{v}\cdot\vec{v}\tag{1.2.9}

$$

So, the offcial definition of the “length” is:

DEFINITION: The length $||\vec{v}||$ of a vector $\vec{v}$ is the square root of $\vec{v}\cdot\vec{v}$

$\text{Length}=\text{norm}(\vec{v})$

$$

\text{length}=||\vec{v}||=\sqrt{\vec{v}\cdot\vec{v}}\tag{1.2.10}

$$

More than two deminsional vectors can also calculate their length with this definition, if $\vec{v}$ is n-dimension vector, its length is:

$$

||\vec{v}||=\sqrt{\sum_{i=1}^{n}v_i^2}\tag{1.2.11}

$$

### Length 0 is Special

However, we can get number 0 by do dot product of two perpendicular vectors, but the only vectors whose length is 0 are zero vectors, no matter how many deminsions they are.

This is easy to proof, considering the formula 1.2.11, the part under $\sqrt{}$ is always equal or bigger than zero,and if and only if all $v_i$ is zero, it equals to zero. So the 0-length vectors are only zero vectors.

## Unit Vectors

0 is special, so is 1.

DEFINITION A unit vector $\vec{u}$ is a vector whose length equals one. Then $\vec{u}\cdot\vec{u}=1$

An easy 4-deminsion vector whose length is $\vec{u}=(\frac{1}{2},\frac{1}{2},\frac{1}{2},\frac{1}{2})$ Then his length is $\sqrt{\vec{u}\cdot \vec{u}}=\sqrt{\frac{1}{2}^2+\frac{1}{2}^2+\frac{1}{2}^2+\frac{1}{2}^2}=1$. We have infintiy unit vectors in any dimension.

### Create Unit Vectors

The unit vectors’ basic property is their length is always 1, So, we can draw a unit circle(radius is 1), then every co-ordinate of the points on the circle can compose a vector. So this can be write as:

$$

\vec{v}=(cos\theta,sin\theta)\tag{1.2.12}

$$

where, points $(cos\theta,sin\theta)$ are on the circle, and the distance between the points and origin are $\sqrt{cos^2\theta+sin^2\theta}=1$ (This is also known as “Euler’s formula”). This works not only in two dimensions condition, but also in higher dimensions, where the circle become n-sphere.

## The Angle between Two Vectors — $90^\circ$

“Perpendicular” has been mentioned above, when the result of dot product of two vectors came to 0, these two vectors are perpendicular, and angle between two vectors is connected with dot products, however, if $\vec{v}\cdot \vec{w}=0$ we say the angle between $\vec{v}$ and $\vec{w}$ is $90^{circ}$.

According to the definition of perpendicular, I have to say zero vectors are always perpendicular to every vector with the same dimensions. These seems incredible, but it is the true.

All the conclusion can be proofed by **the Pythagoras Laws** $a^2+b^2=c^2$:

$$

\begin{aligned}

||\vec{v}||^2+||\vec{w}||^2=&||\vec{v}-\vec{w}||^2\newline

v_1^2+v_2^2+w_1^2+w_2^2=&(v_1-w_1)^2+(v_2-w_2)^2\newline

v_1^2+v_2^2+w_1^2+w_2^2=&v_1^2+w_1^2-2v_1w_1+v_2^2+w_2^2-2v_2w_2\newline

-2v_1w_1-2v_2w_2=&0\newline

v_1w_1+v_2w_2=&0

\end{aligned}\tag{1.2.13}

$$

Q.E.D.

The sign of dot product can immediately tell us wheter the angle of these two vectors are below or above $90^\circ$.

1. Sign of the dot product is positive — the angle between these two vectors are below $90^\circ$

2. Sign of the dot product is negative — the angle between these two vectors are above $90^\circ$

3. Sign of the dot product is neither positive nor nagetive — 0 ,of cource — the angle between these two vectors are $90^\circ$

We can also use dot products to calculate the accurate angles of two vectors, but that is used more in geometry not in AI or CS, so we omit those details

## Conclusion

- How to calculate dot products
- What the length of a vector is, and how to calculate it
- Unit vectors
- Relation of “perpendicular” and “dot products”

## Reference

1.Strang G, Strang G, Strang G, et al. Introduction to linear algebra[M]. Wellesley, MA: Wellesley-Cambridge Press, 1993.

## Leave a Reply