# Deriving the formula for calculating the length of the project of the vector $a$ onto the vector $b$

My situation: I am currently taking a course in linear algebra and I am quite all the time. I have however miraculously reached projections in 2-dimensions. I am studying and learning both from course material but also from this article and I am stuck about between page 6 and 7. My question is:

My problem: I wanted to know how to derive the formula for projection of a vector $$a$$ onto a linearly independent vector $$b$$, in order to understand because I am so lost. Why is this text, linked above, and my course book defining the dot product between two vectors as:

$$a\cdot b=|a|*|b|*cos(\theta)$$

and then calculating the length of the projection of the vector $$a$$ onto the vector $$b$$ as:

$$|a_b|=\frac{a\cdot b}{|a|}=\frac{a_x*b_x+a_y*b_y}{|a|}$$

However the dot product is defined as being the product of the length of $$|a|$$, $$|b|$$ and $$cos(\theta)$$ where $$\theta$$ is the angle between the two vectors. If I follow my course book, the slideshows provided by my professor and the pdf link above I am not in fact calculating the dot product and using it to calculate the length of the projection. I am in the example in the pdf calculating some random sum of $$a_x*b_x+a_y*b_y$$ instead of $$\sqrt{a_x^2+a_y^2}*\sqrt{b_x^2+b_y^2}*cos(\theta)$$.

How do you derive $$\sqrt{a_x^2+a_y^2}*\sqrt{b_x^2+b_y^2}*cos(\theta) = a_x*b_x+a_y*b_y$$ and why this difficult change? And why is this equation shift not mentioned? Am I missing something?

• The law of cosines explains the equivalence. Jan 12, 2021 at 17:28
• @Randall, you are very correct! I scrolled up and looked at how the author derived the dot product using, among other things, the law of cosines and saw the equivalence at the bottom of the proof. Thanks a lot! You're a life saver Randall! Jan 12, 2021 at 18:06