Exchanging dot product with matrix multiplication

103 Views Asked by At

If I have an equation that involves both dot product and a matrix multiplication, then what are the rules for exchanging operations between them? For instance, the equation for projection of a vector b onto a is often written as:

$$xa=\frac{a^Tb}{a \cdot a} $$

Then, the "derivation" of the projection matrix is done by:

$$Pb = xa$$

$$Pb = \frac{a^Tb}{a \cdot a}a = a\frac{a^Tb}{a \cdot a} = \frac{aa^T}{a \cdot a}b$$

$$ \therefore P = \frac{a a^T}{a \cdot a} $$

Is anything allowed so long as we respect the rules of matrix multiplication? In particular, I am looking at the second step, where we move the scalar c around, $ca = ac$; it seems hacky to me.