# What is the dot product and why do we need it?

I understand how to calculate the dot product of the vectors. But I don't actually understand what a dot product is, and why it's needed.

• One use is to quantify how 'aligned' two vectors are. In particular, if the dot product of two vectors is zero, they are deemed orthogonal. – copper.hat Jan 6 '14 at 18:46

Dot products are very geometrical objects. They actually encode relative information about vectors, specifically they tell us "how much" one vector is in the direction of another. Particularly, the dot product can tell us if two vectors are (anti)parallel or if they are perpendicular.

We have the formula $\vec{a}\cdot\vec{b} = \lVert \vec{a}\rVert\lVert \vec{b}\rVert\cos(\theta)$, where $\theta$ is the angle between the two vectors in the plane that they make. If they are perpendicular, $\theta = 90^{\circ}, 270^{\circ}$ so that $\cos(\theta) = 0$. This tells us that the dot product is zero. This reasoning works in the opposite direction: if the dot product is zero, the vectors are perpendicular.

This gives us a quick way to tell if two vectors are perpendicular. It also gives easy ways to do projections and the like.

• Good explanation... and it's interesting to note that this interpretation of projection goes far beyond the scope of geometry. You can use (in fact, you do use) this notion on much more abstract vector spaces, like the Hilbert Spaces. The projection here is essential for applications in the statistical interpretation of Quantum Mechanics. Anyway, the important is that dot product measures how much one (abstract) vector is in the direction of the other. – GabrielF Jan 6 '14 at 23:52
• What an unnecessary edit to my answer. – Cameron Williams May 8 '17 at 14:22

That's a huge question. It's what's called an inner product. A good short answer is that it gives you a way to make sense of what an angle between two vectors is. $$\theta = \cos^{-1}\left( \frac{a\cdot b }{|a||b|} \right)$$

In a general vector spaces you can define the length of a vector by the induced norm via $$\|x\| = \sqrt{x\cdot x}$$

this is possible because the dot product is positive definite and thus $x\cdot x$ is not-negative.

It is even possible to define an angle between to vectors this way by

$$\phi = arccos \frac{x\cdot y}{\sqrt{x\cdot x}\cdot\sqrt{y \cdot y}}$$

also two vector are orthogonal iff their inner product is zero, i.e.

$$x \perp y \Longleftrightarrow x\cdot y = 0$$

Note that this is possbile for every vector space that has an inner product (dot product)

A more special example could be: Take the vector space of the continous functions on the intervall $\left[-1,1\right]$ with the inner product defined by $\int_{-1}^1 f(x)g(x) dx$, then the functions $f(x)=x$ and $g(x)=x^2$ are orthogonal, because $$\int_{-1}^{1}x\cdot x^2 dx = \int_{-1}^{1} x^3 dx = 0$$

And the length of $f$ would be

$$\left\|f\right\| = \sqrt{\int_{-1}^{1}x\cdot x\, dx } = \sqrt{\frac{2}{3}}$$

• If-and-only-if is spelled "iff", not "iif". – AJMansfield Jan 7 '14 at 2:40
• I'd be surprised if the OP gets any benefit from examples involving vector spaces of functions. – bubba Jan 7 '14 at 13:09
• @bubba It's just an additional example to illustrate that this works for every vector space with an inner product. The real answer is clearly seperated above the "-----" – user127.0.0.1 Jan 7 '14 at 13:15
• @bubba : you are probably right, but this is not a bad example, and it is not harmful to provide more than one viewpoint. Every other answer as already addressed finding the angle between two vectors... – ADA May 8 '17 at 14:22

If the length of $B$ is $1$ then $\langle A,B\rangle$ is the coordinate of $A$ in direction $B$.

There is a nice interpretation of the scalar product where $B$ has arbitrary length. Let $B=(b_1,b_2)$, then define $J(B):=(-b_2,b_1)$; you'll get $J(B)$ by rotating $B$ counterclockwise by $\pi/2$. Observe that $$\langle A, B\rangle=\det\bigl(A,J(B)\bigr),$$ that is: the dot product is the (orientated) area of the parallelogram spanned by $A$ and $J(B)$.

Consider two points in $\mathbb R^n$, $P=(x_1, x_2, \dots, x_m)$ and $Q=(y_1, y_2, \dots, y_n)$. Let $O=(0,0,\dots, 0)$ be the origin. How do you find $\theta = m\angle POQ$? According to the law of cosines, $$\cos \theta = \dfrac{|P|^2 +|Q|^2-|Q-P|^2}{2|P|\cdot|Q|}$$.

$$|P|^2=\sum_{i=1}^n x_i^2$$ $$|Q|^2=\sum_{i=1}^n y_i^2$$ $$|Q-P|^2=\sum_{i=1}^n (y_i-x_i)^2 =\sum_{i=1}^n (x_i^2+2x_iy_i+y_i^2)$$

It follows that $\displaystyle |P|^2 +|Q|^2-|Q-P|^2 = 2\sum_{i=1}^n x_iy_i$

So $$\cos \theta = \frac{\sum_{i=1}^n x_iy_i}{|P|\cdot|Q|}$$.

It is convenient to define the dot product $P \circ Q = \sum_{i=1}^n x_iy_i$.

So now consider an n-dimensional vector space $\mathbf V$ with a basis $\{\mathbf e_i\}_{i=1}^n$. Given $P=\sum_{i-1}^n x_i \mathbf e_i$ and $Q=\sum_{i-1}^n y_i \mathbf e_i$ we define $P \circ Q = \sum_{i=1}^n x_iy_i$ and we define $P$ is orthogonal to $Q$ when $P \circ Q = 0$.

We can now define the angle, $\theta$ between the vectors $P$ and $Q$ by $\cos \theta = \dfrac{P \circ Q}{|P| \cdot |Q|}$.

Thus the dot product is just an abstraction of a property of vectors in the Euclidean plane. From here we can now define what an orthogonal and an orthonormal basis are and find some very interesting consequences. Yes, there are a lot of technical problems that need to be solved, but they can be solved.