MathLabs

Problem 1

Let x1≥x2≥⋯≥xnx_1 \ge x_2 \ge \cdots \ge x_n and y1≥y2≥⋯≥yny_1 \ge y_2 \ge \cdots \ge y_n be real numbers. Prove that if z1,z2,…,znz_1, z_2, \ldots, z_n is any permutation of y1,y2,…,yny_1, y_2, \ldots, y_n, then ∑i=1n(xi−yi)2≤∑i=1n(xi−zi)2\sum_{i=1}^{n} (x_i - y_i)^2 \le \sum_{i=1}^{n} (x_i - z_i)^2.
Step 3 of 5: Key lemma: swapping an out-of-order pair never decreases the dot product
In plain words

With just two numbers this is the whole problem in miniature: if car AA is bigger than car BB but spot AA is smaller than spot BB, swapping the cars to match sizes can only shorten the total parking distance, never lengthen it.

p<q, zp<zq  ⟹  xpzp+xqzq≤xpzq+xqzpp<q,\ z_p<z_q \implies x_pz_p+x_qz_q \le x_pz_q+x_qz_p
Detailed analysis

Suppose in some permutation zz there are positions p<qp<q with zp<zqz_p < z_q (an "inversion": a smaller value sits where a larger xx is, since xp≥xqx_p \ge x_q). Swap zpz_p and zqz_q; every other term of ∑xizi\sum x_iz_i is unchanged, so it suffices to compare xpzp+xqzqx_pz_p+x_qz_q with xpzq+xqzpx_pz_q+x_qz_p. Their difference is (xpzq+xqzp)−(xpzp+xqzq)=(xp−xq)(zq−zp)≥0(x_pz_q+x_qz_p)-(x_pz_p+x_qz_q) = (x_p-x_q)(z_q-z_p) \ge 0, because xp≥xqx_p \ge x_q and zq>zpz_q > z_p by assumption. Hence swapping the inversion into the correct order weakly increases ∑xizi\sum x_iz_i.