Archived

This topic is now archived and is closed to further replies.

boomji

dot product and it's derivation

Recommended Posts

hi, googled around first but did not find what i was looking for. any way,could any one tell me why is the dot product ||A||*||B||cos theta. Every where i read up this was a given(cos theta). now i know i may not yet be abel to digest the proof even if it was explained but i''m hoping some one could post a visual explanation or point me to one...please. thanks for your time. b

Share this post


Link to post
Share on other sites
The definition of the dot product for two vectors and is Ax*Bx + Ay*By. Also, Aθ is arctan(Ay/Ax) and Bθ is arctan(By/Bx). SO:

dot(A,B) = Ax*Bx + Ay*By
= ||A||cos(Aθ ) * ||B||cos(Bθ ) + ||A||sin(Aθ ) * ||B||sin(Bθ )

= ||A|| * ||B|| * cos(Aθ ) * cos(Bθ ) + ||A|| * ||B|| * sin(Aθ ) * sin(Bθ )

= (||A|| * ||B||)(cos(Aθ ) * cos(Bθ ) + sin(Aθ ) * sin(Bθ ))

and, by some product-to-sum trig identities:

= (||A|| * ||B||)((1/2 * cos(Aθ - Bθ ) + cos(Aθ + Bθ ))+(1/2 * cos(Aθ - Bθ ) - cos(Aθ + Bθ )))

= (||A|| * ||B||) * 1/2 * (cos(Aθ - Bθ ) + cos(Aθ + Bθ )+cos(Aθ - Bθ ) - cos(Aθ + Bθ ))

= (||A|| * ||B||) * 1/2 * (cos(Aθ - Bθ )+cos(Aθ - Bθ ))

= (||A|| * ||B||) * cos(Aθ - Bθ )

TADA!



How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Let''s do it backwards.

Let''s say you have 2 vectors in 3D, and you want to find |A|*|B|*cos theta. Does this reduce to Ax * Bx + Ay * By + Az * Bz? Let''s see.

|B|*cos theta is the length of the projection of vector B onto vector A. Let''s find the point on vector A of this projection.

Let''s call the coordinates of this point (Cx, Cy, Cz).

Now, let''s create a plane that has its normal as vector A - and let''s set this plane to intersect with the endpoint of vector B. The intersection of this plane with vector A will yield (Cx, Cy, Cz)!

This plane is:
Ax * x + Ay * y + Az * z = K, where K is some constant

Now, this plane must intersect with (Bx, By, Bz) as stated above.

Ax * Bx + Ay * By + Az * Bz = K

So the equation of the plane is:

Ax * x + Ay * y + Az * z = Ax * Bx + Ay * By + Az * Bz

Let''s find out how far this plane is along vector A.

Let''s represent vector A as a parametric line:

x = Ax * t / |A|
y = Ay * t / |A|
z = Az * t / |A|

We must divide by |A| in order to make t the actual distance along vector A. (i.e. an increment of 1 in t travels 1 unit)

Sub that in to the plane:

Ax * Ax * t / |A| + Ay * Ay * t / |A| + Az * Az * t / |A| = Ax * Bx + Ay * By + Az * Bz

Ax^2 * t / |A| + Ay^2 * t / |A| + Az^2 * t / |A| = Ax * Bx + Ay * By + Az * Bz

Ax^2 * t + Ay^2 * t + Az^2 * t = |A| * (Ax * Bx + Ay * By + Az * Bz)

Since Ax^2 + Ay^2 + Az^2 = |A|^2:

|A|^2 * t = |A| * (Ax * Bx + Ay * By + Az * Bz)

t = (Ax * Bx + Ay * By + Az * Bz)/|A|

Since t is the distance along vector A of the projection of vector B, t = |B| * cos theta

Therefore:

|A| * |B| * cos theta

= |A| * t

= |A| * (Ax * Bx + Ay * By + Az * Bz)/|A|

= Ax * Bx + Ay * By + Az * Bz

Wow ... that actually worked!

Share this post


Link to post
Share on other sites
Take A = |A|*a, B = |B|*b so that the vectors a=(ax,ay) and b=(bx,by) are unit vectors.

1) I think the factors |A| and |B| are clear then (put it into the equations if you don´t believe it, also the scalar product is bilinear by definition).

2) a*b is the projection of vector a on vector b (which happenes to be the same as the projection of b on a). Let both a and b lie in the xy-plane and let b be a unit vector in the x-direction (you might want to think about why/if that assumption is ok in a general case after you understood the following).
Draw both vectors in your coordinate system. Draw a triangle with points (0,0), (ax, ay), (ax, 0) which is a recangular triangle (vector (ax,0) is the projection of a on b as you will see).
By the geometrical definition of cos you´ll see that cos(theta) = |(ax,0)|/|(ax,ay)| = |projection(a -> b)|/1 = a*b.

EDIT: The |(ax,0)| above is not completely correct since it can also be negative when a is in the 2nd or 3rd quadrant but you´ll see from your picture what I meant.

[edited by - Atheist on October 22, 2003 2:56:34 AM]

Share this post


Link to post
Share on other sites
Actually guys, the dot product between 2 vectors A, B is DEFINED as |A||B|cos theta. Most people (mistakingly) get it the wrong way round, A.xB.x + A.yB.y + A.zB.z is NOT the definition of the dot product, it is merely a reduction of the definition into component form. The reduction is just an easier way of computing the dot product, and it follows from several different methods of reduction: one of which is Tron3k''s reduction.

Here is another reduction which I found interesting and in my opinion more visually and mathematically intuitive.

(1) A.B = |A||B|cos(theta) (by defn of dot product)

If you think of the length of the 3 vectors |A|,|B| and |B-A| as the lengths of the sides of a triangle, you can apply the law of cosines here too (boomji, to visualize this, draw the 2 vectors A and B onto a graph, now the vector from A to B will be given by B-A. The triangle formed by these 3 vectors is applied to the law of cosines for a triangle :D)
c^2 = a^2 + b^2 - 2.a.b.cos(C)
In this case, we substitute: |B-A| for c, |A| for a, |B| for b
and we obtain:

(2) |B-A|^2 = |A|^2 + |B|^2 - 2 |A|.|B|.cos(Theta) (by law of cosines)

Remember now, that Theta is the angle between the 2 vectors A, B.
Notice the common term |A||B|cos(Theta) in both equations. We now equate equation (1) and (2), and obtain

A.B = (-(|B-A|^2) + |A|^2 + |B|^2) / 2
and hence
A.B = (-((B.x^2 - 2A.xB.x + A.x^2) + (B.y^2 - 2A.yB.y + A.y^2) + (B.z^2 - 2A.zB.z + A.z^2)) + A.x^2 + A.y^2 + A.z^2 + B.x^2 + B.y^2 + B.z^2) / 2
(by pythagorean length of a vector) and thus
A.B = A.xB.x + A.yB.y + A.zB.z

This one I think is more visually explainable. Unfortunately, I don''t have the time to draw a diagram, sorry!

Hope this helped!


Share this post


Link to post
Share on other sites
Where did you get that way of definition (and what makes you think your source is THE definition)? I always thought the dot product is a special scalar product which is (in the form I know) given as a multilinear positive definite symmetric form over a vector space.
Also if the two forms are equal (which is only true in the case of a real vector space because you can´t define an angle in general) where is the point in marking one form as THE definition?

Share this post


Link to post
Share on other sites


hi there,
thanks so much folks...and pretty detailed as well.
the cosine rule and it's involvement here has made most of the cogs in my block head turn so i will definately look into that area more(did not do math beyound 10th grade...came right back at me and bit me in the moon there didn't it ).
thanks a ton guys...going to save this page and thoroughly go through it.

b

[edited by - boomji on October 22, 2003 1:51:18 PM]

Share this post


Link to post
Share on other sites
Hey Athiest, don''t be mistaken - the idea that that is the definition of dot-product is not just simply an idea that popped into my head. It was an idea strictly enforced by the mathematics academics whilst I was doing my degree. More generally, though the definition pertains to Euclidean space rather than Inner-product spaces.Sorry to have made such a broad statement - I guess that''s just asking for trouble (even if I am right :D) ... but by all means, prove me wrong

The point of proper definitions: learning and common language, although in this case they may clear up confusion of certain concepts. Such as the origin of the projection of a vector onto another vector, which has it''s basis in geometric and trigonometric methods and which is more easily explained by the definition |A||B|cosC of the dot product.

Share this post


Link to post
Share on other sites
hmm.. taking a look at the "geometrical analysis" section of my "handbook of mathematics" (bronstein, semendjajew - dunno if this book exists in an english version) it seems that you´re right.
I still think the multilinear-form approach is better because it´s more general (I know this is a very subjective statment). But I can live with the idea of fixing the remaining degree of freedom (so that A scalar product becomes THE dot product) with a geometrical postulation/demand/claim (whatever the correct word is) - the cos-thing.

Share this post


Link to post
Share on other sites
The neat thing about the |A||B|cosC definition of the dot product is that the equation does not change with different numbers of dimensions, as opposed to AxBx+AyBy and AxBx+AyBy+AzBz, etc. Nice static definition applicable to space of any number of dimensions.

Share this post


Link to post
Share on other sites
Doc, I agree with you except for the fact that you still have to calculate the length of your A and B vectors - which requires the sum of componentwise multiplications anyway :D

Athiest, just to address one of your earlier points: it does seem kinda tricky defining the angle for vectors of more than 2 dimensions. However, it also seems that even the pythagorean length of vectors for more than 3 dimensions doesn''t make sense either - how would you factor (x,y,z,smell) into a length? Well, that''s maths for you - the theory comes first (several hundred years before at times), and then the application...
Maybe one day we will be able to rationalize things like the angle in 103 dimensional space and the length of a 45 dimensional vector, but till then, I guess I''ll just stick with what I know and what other people can teach me and just rely on the basis of maths.

Share this post


Link to post
Share on other sites
>> how would you factor v=(x,y,z,smell) into a length?

with length(v) = ||v||. It´s called the norm and makes your vector space a normed vector space (that´s one where you can measure lenghts).
Maybe I should also clearify that by "more general" I wasn´t just referring to vector spaces R^n but to any vector spaces. Also don´t think that vector spaces other than euclidean R^n are science fictional. They are absolutely standard being used in differential geometry (theory of relativity) and in quantum mechanics (you´d have a hard time defining a geometrical angle between two gaussians).
btw.: You could start spelling my name correctly

Doc: Try < x | y > = x1y (1 being the unit matrix).

[edited by - Atheist on October 26, 2003 9:14:03 AM]

Share this post


Link to post
Share on other sites
Sorry for reviving this thread (1 week old) but I thought you should know:

Richard Feynman uses the formula:

axbx + ayby + azcz = a*b

when he defines the dot product. This is explained in volume 1 chapter 11 of his lectures.

The reason for which I think people say that dot product is |a||b|*cos(theta) is because of the way it was computed the first time. People obviously defined in the beginning scalar product like that (we can actually SEE what this means).

After this, when linear algebra was invented, people became interested in having a generalization of this stuff. The second formula was appliable in many more situations than the second formula (and was able to define the angle between two vectors in n-dimensional spaces). THe second formula (with the cosinus) became just a geometric interpretation of the limited case with 3 or 2 dimensions.

The cos formula for the dot product was important because it allowed a very important generalization, but the RIGHT definition is that without cos.

Share this post


Link to post
Share on other sites
quote:
... but the RIGHT definition is that without cos.

That is simply not true. There is no one right definition. Those 2 definitions are equivalent, but in different terms. Which definition you should use depends upon the context of the problem.

The dot product itself is just the inner product of two 3D vectors.



[edited by - Mastaba on November 3, 2003 8:08:57 PM]

Share this post


Link to post
Share on other sites