Deriving the OLS formula
Summary
Let
f(b1,b2)=RSS=n∑i=1e2i=n∑i=1(yi−b1−b2xi)2
Then
∂f∂b1=−2n∑i=1(yi−b1−b2xi)
∂f∂b2=−2n∑i=1xi(yi−b1−b2xi)
The first order conditions give us the normal equations
n∑i=1(yi−b1−b2xi)=0
n∑i=1xi(yi−b1−b2xi)=0
The solution to this system of equations is the OLS formula.