# Small trouble with summation algebra Wouldn't the first term below leads to the final term?

$$\hat{\beta_1}={\sum_{i=1}^n c_iy_i} = {\sum_{i=1}^n \frac{(x_i-\bar{x})(y_i)}{SXX}} = {\sum_{i=1}^n \frac{(x_i-\bar{x})(y_i)}{{\sum\limits_{i=1}^n (x_i-\bar{x})^2}}} = \frac{SXY}{SXX},$$ which is very different from $$\frac{\sum\limits_{i=1}^n{(x_i-\bar{x})(y_i)}}{{\sum\limits_{i=1}^n (x_i-\bar{x})^2}} = \frac{SXY}{SXX}=\hat{\beta_1}.$$

I am confused about how, in the first line, the author factored out was able to factor out the $SXX$ term from inside the summation.

• @LtotheV Note that $c:=\dfrac1\sum_{j=1}^n(x_j-\overline x)^2$ is a constant irrelevant to the summation index $k$ in the outer summation, thus$$\sum_{k=1}^nc(x_k-\overline x)y_k=c\sum_{k=1}^n(x_k-\overline x)y_k.$$ – Saad May 27 '18 at 3:30
• @LtotheV In fact, it's incorrect to use $i$ in both outer and inner summation. – Saad May 27 '18 at 4:05
• @LtotheV $i$ can be used in both outer and inner summation like $\sum\limits_{i=1}^n\left(x_i+\sum\limits_{j=1}^i(a_jy_i+b_j)\right)$, but $i$ as the summation index for the outer sum cannot be used again as summation index in the inner one like $\sum\limits_{i=1}^n\left(x_i+\sum\limits_{i=1}^n(a_iy_i+b_i)\right)$, which is ambiguous. – Saad May 28 '18 at 7:12