# Given four real numbers $a_1<a_2<a_3<a_4$, rearrange them in such an order $a_{i_1}$, $a_{i_2}$, $a_{i_3}$, $a_{i_4}$ that the sum

Given four real numbers $$a_1 \lt a_2 \lt a_3 \lt a_4$$, rearrange them in such an order $$a_{i_1} , a_{i_2} , a_{i_3} , a_{i_4}$$ that the sum

$$S = (a_{i_1}-a_{i_2})^2 + (a_{i_2}-a_{i_3})^2 + (a_{i_3}-a_{i_4})^2 + (a_{i_4}-a_{i_1})^2$$ has the least possible value? Can you generalise for $$n$$ real numbers?

I opened up the equation but it was not of much use.

We can observe that the $$3$$ inequalities hold:

1) $$a_4-a_1 \gt a_3-a_1 \gt a_2-a_1$$
2) $$a_4-a_1 \gt a_4-a_2 \gt a_4-a_3$$ .
3) $$a_4-a_2 \gt a_3-a_2$$

And I believe the order giving the smallest $$S$$ will be given by $$a_4, a_2, a_1, a_3$$ which is equivalent to the sum if the order is $$a_4, a_3, a_1, a_2$$,

so

$$S = (a_{i_4}-a_{i_2})^2 + (a_{i_2}-a_{i_1})^2 + (a_{i_1}-a_{i_3})^2 + (a_{i_3}-a_{i_4})^2$$

and

$$S = (a_{i_4}-a_{i_3})^2 + (a_{i_3}-a_{i_1})^2 + (a_{i_1}-a_{i_2})^2 + (a_{i_2}-a_{i_4})^2$$

Although I am not sure on how to prove this, any help would be appreciated, thank you.

• Possible duplicate of Prove that $f(a,c,b,d) > f(a,b,c,d) > f(a,b,d,c).$ – Martin R Mar 19 at 12:06
• Just adding that the above link indeed contains all rearrangements one needs to consider. In general, there are $4! = 24$ rearrangements of these numbers, but firstly since $abcd$ yields the same sum as the cyclic permutations $bcda,cdab,dabc$, for every rearrangement there are four redundant ones, so 24/4 = 6 rearrangements up to these cyclic ones. But additionally, for every arrangement $abcd$ the reverse arrangement $dcba$ also yields the same sum, so perform another division 6/2 = 3. So the above three options $acbd, abcd, abdc$ are the only ones one needs to care about. – Lukas Miristwhisky Mar 19 at 14:36