# While deriving Least Squares Estimators, how to find the derivate of a summation operate?

I'm calculating the Least Squares Estimators. There was one step here:

$$\frac{d}{d\hat\alpha}{\sum(y_i-\hat\alpha-\hat\beta x_i)}^2=0$$ --> $$-2{\sum(y_i-\hat\alpha-\hat\beta x_i)}=0$$

I know it is related to the chain rule, yet I don't know how it is applied here. Can someone please explain? Huge huge thanks!

• derivative of (a+b) = derivative of a + derivative of b. Oct 12 at 19:16
• @seanv507 I'm not sure that's the most relevant derivative rule being used, here. The chain rule is the key. Oct 12 at 19:46

We have \begin{align*} \frac{d}{d\hat\alpha}\sum_{i=1}^n(y_i-\hat\alpha-\hat\beta x_i)^2 &=\sum_{i=1}^n\frac{d}{d\hat\alpha}(y_i-\hat\alpha-\hat\beta x_i)^2\\ &=\sum_{i=1}^n2(y_i-\hat\alpha-\hat\beta x_i)\cdot\frac{d}{d\hat\alpha}(y_i-\hat\alpha-\hat\beta x_i)\quad\text{(chain rule)}\\ &=\sum_{i=1}^n2(y_i-\hat\alpha-\hat\beta x_i)\cdot(-1). \end{align*}