Least Squares Lemma
Before proceeding, another sequence of formulas is presented:
$$
w_1 (x-A)^2 + w_2 (x-B)^2 =
w_1 x^2 - 2 w_1 A x + w_1 A^2 +
w_2 x^2 - 2 w_2 B x + w_2 B^2 =
$$ $$
(w_1 +w _2) \left[
x^2 - 2 \frac{w_1 A + w_2 B}{w_1 + w_2} x +
\left( \frac{w_1 A + w_2 B}{w_1 + w_2} \right)^2 \right]
$$ $$
- \frac{(w_1 A + w_2 B)^2}{w_1 + w_2} +
\frac{(w_1 A^2 + w_2 B^2)(w_1 + w_2)}{w_1 + w_2} =
$$ $$
(w_1 + w_2)\left[x - \frac{w_1 A + w_2 B}{w_1 + w_2}\right]^2
$$ $$
- \frac{w_1^2 A^2 + 2 w_1 w_2 A B + w_2^2 B^2}{w_1 + w_2} +
\frac{w_1^2 A^2 + w_1 w_2 A^2 + w_2^2 B^2 + w_1 w_2 B^2}{w_1 + w_2} =
$$ $$
(w_1 + w_2)\left[x - \frac{w_1 A + w_2 B}{w_1 + w_2}\right]^2 +
\frac{w_1 w_2}{w_1 + w_2} (A^2 - 2 A B + B^2)
$$
The result is a Lemma:
$$
w_1 (x-A)^2 + w_2 (x-B)^2 =
(w_1 + w_2)\left[x - \frac{w_1 A + w_2 B}{w_1 + w_2}\right]^2 +
\frac{w_1 w_2}{w_1 + w_2} (A - B)^2
$$