Deriving the OLS formula

Summary

Let

f(b1,b2)=RSS=ni=1e2i=ni=1(yib1b2xi)2

Then

fb1=2ni=1(yib1b2xi)

fb2=2ni=1xi(yib1b2xi)

The first order conditions give us the normal equations

ni=1(yib1b2xi)=0

ni=1xi(yib1b2xi)=0

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