Deriving the OLS formula

Summary

Let

\[f\left( b_1,b_2 \right)=RSS=\sum_{i=1}^{n}{ e_i^2 }=\sum_{i=1}^{n}{ {\left( y_i-b_1-b_2x_i \right)}^2 }\]

Then

\[ \frac{∂f}{∂b_1}=-2\sum_{i=1}^{n}{ \left( y_i-b_1-b_2x_i \right) }\]

\[ \frac{∂f}{∂b_2}=-2\sum_{i=1}^{n}{ x_i\left( y_i-b_1-b_2x_i \right) }\]

The first order conditions give us the normal equations

\[\sum_{i=1}^{n}{ \left( y_i-b_1-b_2x_i \right) }=0\]

\[\sum_{i=1}^{n}{ x_i\left( y_i-b_1-b_2x_i \right) }=0\]

The solution to this system of equations is the OLS formula.