How can I show if $\displaystyle\bar{x}=\sum_{i=1}^n{x_ip_i}$ , then
$\sum_{i=1}^n{p_i\left(x_i-\bar{x}\right)^2}=\frac{1}{2}\sum_{i=1}^n\sum_{j=1}^n{p_ip_j\left(x_i-x_j\right)}^2$
is true?
(This claim is from page 96 of the book, "Cauchy-Schwarz Master Class".)