# Dot, Scalar, Inner Product Question

1. Dec 4, 2008

### Prologue

I have been searching for a way to relate known concepts (known to me) to the computation of the dot product in an effort to understand why it takes the form it does. I ran into a little snippet in a classical dynamics book that seems like it just may be the ticket.

Here is what it says:
From analytical geometry we recall that the formula for the cosine of the angle between two line segments is ​

$$cos (\theta) = \frac{A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}}{(A_{x}^{2}+A_{y}^{2}+A_{z}^{2})^{1/2}(B_{x}^{2}+B_{y}^{2}+B_{z}^{2})^{1/2}}$$

Then by rearranging and using a definition of dot product we get:

$$\vec{A}\bullet\vec{B} := A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}$$

$$\vec{A}\bullet\vec{B} = cos(\theta)(A_{x}^{2}+A_{y}^{2}+A_{z}^{2})^{1/2}(B_{x}^{2}+B_{y}^{2}+B_{z}^{2})^{1/2}$$

So the real question is: where in analytical geometry can I find this formula for the cosine of the angle between two line segments?

2. Dec 4, 2008

### tiny-tim

Hi Prologue!

it's the cosine rule:

(a - b).(a - b) = a.a + b.b - 2√(a.a)√(b.b)cos(c)

3. Dec 4, 2008

### quasar987

I just tried it and it is pretty straightforward. Start with two vectors $\vec{A}$ and $\vec{B}$. Normalize $\vec{B}$ by setting $\vec{B'}:=\vec{B}/||\vec{B}||$ and let c be the constant such that $||\vec{cA}||^2+||\vec{B'}-(cA)||^2=1$. This means that c is the scaling constant such that B' and cA form a right angled triangle with B' as the hypothenuse. Now by definition of the cosine of an angle (if I remember my high school math correctly), $\cos\theta = ||c\vec{A}||$.

So just solve for c in the equation above and inject in the defining equation for cos\theta. I tried it and it works!

4. Dec 5, 2008

### Prologue

I see, but it isn't what I was looking for *deflation*. But even though that didn't lead me to a satifying conclusion, maybe I can and pose it differently.

I am really just trying to figure out why it is so darn simple. To find a dot product, you just take the contributions of the vectors in the same direction, multiply, then repeat, then sum. Why should it be (hopefully based on a visual/spatial argument *fingers crossed*) that this is the way that works?

We say things like, the projection of A onto B, or something of the sort. And when you break them into components, it literally is THE projection of each component onto the others component, then sum them. Why is it that this works?

It's so simple that it is begging for a simple explanation.

5. Dec 5, 2008

6. Dec 7, 2008

### tiny-tim

Hi Prologue!

I think it's ultimately because perpendicular vectors have zero dot-product, and components in different directions are perpendicular, so when you multiply two vectors, you end up just multiplying the "same-direction" component-pairs, and adding:

(∑i aiei).(∑i biei) = ∑ijaibj(ei.ej) = ∑iaibi(ei.ei) = ∑iaibi

7. Dec 7, 2008

### mathwonk

do you want to know why the law of cosines is true or why math is beautiful?

the law of cosines appears in euclid, and is a corollary of pythagoras.

learning to phrase the law of cosines as a kind of multiplication of vectors is probably due to some obscure genius.

math is beautiful because........?

8. Dec 7, 2008

### Prologue

Thank you for the replies everyone.

I would like to come at it a little different way. I'd like to look at the line of logic that starts with, 'We need something called a Dot Product because we would like to multiply vectors and this is how it works out.', and ends up with the dot prduct identity.

So, we want to multiply vectors. Then, I suppose, we decide that the only sensible way to do that is to say 'we only want to multiply the parts of the vectors that go in the same direction' (say that we put this constraint on as a result of a physical situation, maybe work). We then work out the geometry to find that no matter which vector we use as the reference we end up with the same result (B onto A or A onto B). Well, that is handy but now what is the best way to compute this with our contraint and with the rule we just found about commutation?

Let's say that we have two vectors A and B. A = [Ax,Ay] and B = [Bx,By].

Now let us presume that for the purpose of finding the dot product we can rotate the coordinate axes that we use to measure the vectors, in any direction we please, as long as we preserve the positioning of the vectors relative to each other.

We now have an easy way to find the dot product in 2d. In this case it is merely the component of the vector A in the x' direction, times the magnitude of the vector B.

Now we just have to show that

(1) $$A_{x'}|\vec{B}| = A_{x}B_{x}+A_{y}B_{y}$$

or equivalently

(2) $$|\vec{A}||\vec{B}| cos(t)= A_{x}B_{x}+A_{y}B_{y}$$

Using (2):

$$\sqrt{A_{x}^{2}+A_{y}^{2}}\sqrt{B_{x}^{2}+B_{y}^{2}} cos(t)= A_{x}B_{x}+A_{y}B_{y}$$

Now I just need a way to find cos(t). It's late so I'll quit now and fumble with it some more later.

9. Dec 8, 2008

### tiny-tim

Hi Prologue!

I wish you well on your quest.

Here's a few comments to help/hinder you:

i] you've specified a.b = b.a (commutativity) … but why not a.b = -b.a?

ii] you've specified rotational invariance

iii] shouldn't you specify distributivity: a.(b+c) = a.b + a.c?

iv] what's wrong with a scalar product defined as a.b = absin?

10. Dec 8, 2008

### robphy

11. Dec 8, 2008

### Prologue

i] I think this is shown to not be true numerically in the geometric interpretation and generally when you convert it to algebra. In other words there is no direction associated with the dot product, only whether or not the two vectors have >90 degrees or < 90 degrees between them (the projected components point in 'opposite' directions). :)

ii] Yeah and I think it is clear that it works when looked at geometrically.

iii] Yeah that could be done (as you know) but I struggle to see how it would help. It seems to me that breaking things down into a math notation is good for computing the result, but is not good in this case for visualizing.

iv]Nothing is wrong with it, it just doesn't fit physically (as in trying to find work).

The last post shows basically what I understand of the argument and I think it demonstrates the problem I am having.

Fundamental disconnection:

$$cos(t)=\frac{A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}}{(A_{x}^{2}+A_{y}^{2}+A_{z}^{2})^{1/2}(B_{x}^{2}+B_{y}^{2}+B_{z}^{2})^{1/2}}$$

Why is this true?

I see that it works in certain cases (see below) but what is the generality that makes it all click?

You can see from this diagram that

$$cos(t)=\frac{A_{x}B_{x}+0+0}{AB}=\frac{A_{x}B_{x}}{1}=\frac{A_{x}1}{1}=A_{x}$$

But how is there some visual/geometric generalization that pulls it all together for every relationship?

Last edited: Dec 8, 2008
12. Dec 8, 2008

### D H

Staff Emeritus
It comes from the law of cosines and the Euclidean distance in R3 (or more generally in Rn). Given a triangle with sides a, [/i]b[/i], and c, the angle between the sides a and b is given by

$$\cos\theta = \frac{a^2+b^2-c^2}{2ab}$$

Now imagine a triangle with one vertex at the origin, another at point a and another at point b. Using the Euclidean norm,

\aligned a^2 &= \sum_i a_i^2 \\ b^2 &= \sum_i b_i^2 \\ c^2 &= \sum_i (a_i-b_i)^2 \endaligned

With the above the numerator in the law of cosines becomes

\aligned a^2+b^2-c^2 &= \sum_i a_i^2 + b_i^2 - (a_i-b_i)^2 \\ &= 2\sum_i a_i b_i \endaligned

and thus

$$\cos\theta = \frac{\sum_i a_i b_i}{\sqrt{\sum_i a_i^2}\,\sqrt{\sum_i b_i^2}}$$

13. Dec 8, 2008

### Prologue

Well, D H, I think that pretty much takes care of all of my confusion. Thank you!

And thanks to everyone else, I know it was said many times that it comes from the law of cosines but I just couldn't see where it happened. Now I do, thanks again.