# Understanding formula for projection of a vector onto a line

The formula for projection of a vector 'b' on line represented by vector 'a' is given as the following in Linear algebra and its applications by Gilbert Strang

But why is that after finding the scalar 'x-cap' in the derivation, it is multiplied with the vector representing the line i.e. 'a' and not the unit vector along the line i.e. 'a/||a||'?

Could anyone please explain this ?

When deriving $$\hat x=\frac{a^Tb}{a^Ta}$$, the author starts by assuming that $$\hat x$$ is the coefficient that is needed for $$\hat xa$$ to be the point of projection. He could've said that he wanted $$\hat x\frac{a}{\|a\|}$$ to be this point instead, but then the formula for $$\hat x$$ would look different to compensate for this (it would've been $$\hat x=\frac{a^Tb}{\|a\|}$$ instead).
Since he is assuming from the start that he wants $$p=\hat xa$$, then that is what he gets in the end. Regardless of which assumption you start with, however, you do get $$p=\frac{a^Tb}{a^Ta}a$$ in the end, as the denominator is either $$a^Ta$$ from the original derivation, or it is $$\|a\|\cdot \|a\|=a^Ta$$ from the alternative derivation.