Cos(theta) formula. Please help to understand

Hello fellow students and mentors!
I am a music major, so please bear with me being a dumbass. The Vector Operations Lab has the following formula: cos(πœƒ)=(π‘₯⋅𝑦)/(|π‘₯||𝑦|) Could please someone clarify the meaning? Does it mean the dot product divided by the product of absolute values of the components?
Thank you!

In simple words, it means how close are two vectors between each other

1 Like

Thank you Nydia, I do understand that, just I would want to understand what each of the terms represents…

Hello ossovskiy,

In your question about the dot product, you mentioned the β€˜||’ notation in the denominator. This symbol represents the magnitude (or length) of a vector. Therefore, |x| and |y| denote the lengths of vectors x and y, respectively. The cosine of the angle between these vectors, cos(theta), is equal to the dot product of x and y normalized by the product of their magnitudes. This process is commonly referred to as normalizing the inner product (dot product) in mathematics.

Normalization is crucial because, without it, the dot product can misleadingly suggest a high degree of similarity between vectors that are not very similar, simply due to their large magnitudes. Consider an example where we have two vectors x and y, each with a length of 10,000. Let x = [1, 1, …, 1, 0, 0, …, 0] (with the first 10 elements being 1 and the rest 0), and y = [1, 1, …, 1] (all elements being 1). The dot product of x and y is 10. Now, compare this with two shorter vectors w and z, each of length 10, where w = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] and z = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]. The dot product of w and z is 9.

Despite the smaller dot product, w and z are more similar to each other than x and y. The larger dot product in the case of x and y is due to their greater lengths rather than a greater degree of similarity. Normalization helps us compare vectors as if they all had the same length, thus providing a more accurate measure of similarity per element.

If any further question, feel free to ask.

1 Like

Hi @ossovskiy,

Just to add to @taekyo_lee’s excellent answer:

|π‘₯|: Yes, absolute value. But x is a vector, so it is not about taking away any negative sign. The absolute value of a vector (in Euclidean space) is \sqrt{x_1^2 + x_2^2 + x_3^2} if x is a vector of 3 components. This result is also called β€œlength” or β€œmagnitude” in other context, as @taekyo_lee explained.

Yes. Compute the dot product, divide it by the absolute value of x, and divide it by the absolute value of y.


1 Like

Thank you so much guys for such great answers! It is now all clear.