Normal equation (source code)

= Normal equation

Least-squares differentiation gives $X^TX\widehat\beta=X^TY$, or its precision-weighted analogue.