Go to this page:
On p.2 there are three RHS-expressions of equation 4. How do you go from the first expression to the second expression? Matrices are not like variables x and y, that you can apply FOIL, right?
Furthermore, how can you take the derivative of the result with respect to beta if the matrix beta has more than 1 constituent beta.