A course I'm taking defines the mean of a batch of data with the size $n$ like so:
$$\overline{x} = \frac{\sum_{i=1}^n x_i}{n}$$
And the unbiased sample variance:
$$s^2 = \frac{\sum_{i=1}^n (x_i - \overline{x})^2}{(n-1)}$$
And a second, equivalent way of calculating $s^2$:
$$s^2 = (\sum_{i=1}^n x_i^2 - \frac{(\sum_{i=1}^n x_i) ^ 2}{(n -1)}) * \frac{1}{(n -1)}$$
Now, they didn't show any proof for this, so I thought I try my luck. Let's start with the first version and see what we can rewrite:
$$\begin{align} s^2 &= \frac{\sum_{i=1}^n (x_i - \overline{x})}{(n-1)} \\ &= \frac{\sum_{i=1}^n (x_i^2 - 2\overline{x}x_i + \overline{x}^2)}{(n-1)} \\ &= \frac{\sum_{i=1}^n x_i^2}{(n - 1)} - 2\overline{x} \frac{\sum_{i=1}^nx_i}{(n -1)} + \frac{\sum_{i=1}^n \overline{x}^2}{(n-1)} \end{align}$$
Well, this is as far as I came.
Now, the middle term:
$$2\overline{x} \frac{\sum_{i=1}^nx_i}{(n -1)}$$
I could almost rewrite as $2\overline{x}^2$, buuut that doesn't work because the definition of $\overline{x}$ includes dividing by $n$ and NOT dividing by $(n-1)$.
So, in my opinion, the proof can only work if we define:
$$\overline{x} = \frac{\sum_{i=1}^n x_i}{\color{red}{(n - 1)}}$$
Or am I missing something?
The unbiased sample variance should be $$ \begin{align}s^2 &= \frac{\sum_{i=1}^n (x_i - \overline{x})^2}{n-1} =\frac{\sum_{i=1}^n x_i^2}{n-1}-2\overline{x}\frac{\sum_{i=1}^n x_i}{n-1}+\overline{x}^2\frac{\sum_{i=1}^n 1}{n-1}\\ &=\frac{\sum_{i=1}^n x_i^2}{n-1}-2\overline{x}\frac{n\overline{x}}{n-1}+\overline{x}^2\frac{n}{n-1}\\ &=\frac{\sum_{i=1}^n x_i^2-n\overline{x}^2}{n-1}\\ &=\frac{\sum_{i=1}^n x_i^2-\frac{1}{n}(\sum_{i=1}^n x_i)^2}{n-1}. \end{align} $$