I am reviewing a proof as part of a courser course on regression, but I am getting hung up on some intermediate steps.
The proof we are working is a proof that Y-bar (the average of the individual Y values) is the minimizer for the following formula which is a function of mu:
$$ \sum_{i=1}^{n} (Y_i - \mu)^2 $$
The professor's proof begins as follows:
$$ \sum_{i=1}^{n} (Y_i - \mu)^2 = \sum_{i=1}^{n}(Y_i - \overline{Y} + \overline{Y} - \mu)^2 $$
The next line of the proof is:
$$ = \sum_{i=1}^{n} (Y_i - \overline{Y})^2 + 2\sum_{i=1}^{n} (Y_i - \overline{Y})(\overline{Y} - \mu) + \sum_{i=1}^{n}(\overline{Y} - \mu)^2 $$
My issue is the steps between those lines. I have tried to foil the squared term in my second line above, but was unable to get to the third line. Perhaps I need to work on my algebra related to summations. If anyone can give me any insight into the steps that are occurring here I would greatly appreciate it!
Note that $$\sum_{i=1}^{n}(\color{red}{Y_i - \overline{Y}} + \color{blue}{\overline{Y} - \mu})^2=\sum_{i=1}^n\left[(\color{red}{Y_i-\overline Y})^2+2(\color{red}{Y_i-\overline Y})(\color{blue}{\overline Y-\mu})+(\color{blue}{\overline Y-\mu})^2\right]$$