# Rearrangement inequality

In mathematics, the rearrangement inequality[1] states that

${\displaystyle x_{n}y_{1}+\cdots +x_{1}y_{n}\leq x_{\sigma (1)}y_{1}+\cdots +x_{\sigma (n)}y_{n}\leq x_{1}y_{1}+\cdots +x_{n}y_{n}}$
for every choice of real numbers
${\displaystyle x_{1}\leq \cdots \leq x_{n}\quad {\text{ and }}\quad y_{1}\leq \cdots \leq y_{n}}$
and every permutation
${\displaystyle x_{\sigma (1)},\ldots ,x_{\sigma (n)}}$
of ${\displaystyle x_{1},\ldots ,x_{n}.}$ If the numbers are different, meaning that
${\displaystyle x_{1}<\cdots

then the lower bound is attained only for the permutation which reverses the order, that is, ${\displaystyle \sigma (i)=n-i+1}$ for all ${\displaystyle i=1,\ldots ,n,}$ and the upper bound is attained only for the identity, that is, ${\displaystyle \sigma (i)=i}$ for all ${\displaystyle i=1,\ldots ,n.}$

Note that the rearrangement inequality makes no assumptions on the signs of the real numbers.

## Applications

Many important inequalities can be proved by the rearrangement inequality, such as the arithmetic mean – geometric mean inequality, the Cauchy–Schwarz inequality, and Chebyshev's sum inequality.

One particular consequence is that if ${\displaystyle x_{1}\leq \cdots \leq x_{n}}$ then (by using ${\displaystyle y_{i}:=x_{i}{\text{ for all }}i}$): ${\displaystyle x_{1}x_{n}+\cdots +x_{n}x_{1}\;\leq \;x_{1}x_{\sigma (1)}+\cdots +x_{n}x_{\sigma (n)}\;\leq \;x_{1}^{2}+\cdots +x_{n}^{2}}$ holds for every permutation ${\displaystyle \sigma }$ of ${\displaystyle 1,\ldots ,n.}$

## Intuition

The rearrangement inequality is actually very intuitive. Imagine there is a heap of $10 bills, a heap of$20 bills and one more heap of \$100 bills. You are allowed to take 7 bills from a heap of your choice and then the heap disappears. In the second round you are allowed to take 5 bills from another heap and the heap disappears. In the last round you may take 3 bills from the last heap. In what order do you want to choose the heaps to maximize your profit? Obviously, the best you can do is to gain ${\displaystyle 7\cdot 100+5\cdot 20+3\cdot 10}$ dollars. This is exactly what rearrangement inequality says for sequences ${\displaystyle 10<20<100}$ and ${\displaystyle 3<5<7.}$ It is also an application of a greedy algorithm.

## Proof

The lower bound follows by applying the upper bound to

${\displaystyle -x_{n}\leq \cdots \leq -x_{1}.}$

Therefore, it suffices to prove the upper bound. Since there are only finitely many permutations, there exists at least one for which

${\displaystyle x_{\sigma (1)}y_{1}+\cdots +x_{\sigma (n)}y_{n}}$
is maximal. In case there are several permutations with this property, let σ denote one with the highest number of fixed points.

We will now prove by contradiction, that σ has to be the identity (then we are done). Assume that σ is not the identity. Then there exists a j in {1, ..., n − 1} such that σ(j) ≠ j and σ(i) = i for all i in {1, ..., j − 1}. Hence σ(j) > j and there exists a k in {j + 1, ..., n} with σ(k) = j. Now

${\displaystyle j

Therefore,

${\displaystyle 0\leq \left(x_{\sigma (j)}-x_{j}\right)\left(y_{k}-y_{j}\right).\quad (2)}$

Expanding this product and rearranging gives

${\displaystyle x_{\sigma (j)}y_{j}+x_{j}y_{k}\leq x_{j}y_{j}+x_{\sigma (j)}y_{k}\,,\quad (3)}$

hence the permutation

${\displaystyle \tau (i):={\begin{cases}i&{\text{for }}i\in \{1,\ldots ,j\},\\\sigma (j)&{\text{for }}i=k,\\\sigma (i)&{\text{for }}i\in \{j+1,\ldots ,n\}\setminus \{k\},\end{cases}}}$

which arises from σ by exchanging the values σ(j) and σ(k), has at least one additional fixed point compared to σ, namely at j, and also attains the maximum. This contradicts the choice of σ.

If

${\displaystyle x_{1}<\cdots
then we have strict inequalities at (1), (2), and (3), hence the maximum can only be attained by the identity, any other permutation σ cannot be optimal.

## Proof by induction

Observe first that

${\displaystyle x_{1}>x_{2}\quad {\text{ and }}\quad y_{1}>y_{2}}$
implies
${\displaystyle \left(x_{1}-x_{2}\right)\left(y_{1}-y_{2}\right)>0\quad {\text{ or }}\quad x_{1}y_{1}+x_{2}y_{2}>x_{2}y_{1}+x_{1}y_{2},}$
hence the result is true if n = 2. Assume it is true at rank n-1, and let
${\displaystyle x_{1}>\cdots >x_{n},\quad {\text{ and }}\quad y_{1}>\cdots >y_{n}.}$
Choose a permutation σ for which the arrangement gives rise a maximal result.

If σ(n) were different from n, say σ(n) = k, there would exist j < n such that σ(j) = n. But

${\displaystyle x_{k}>x_{n}\quad {\text{and}}\quad y_{j}>y_{n},\quad {\text{hence}}\quad x_{n}y_{n}+x_{k}y_{j}>x_{k}y_{n}+x_{n}y_{j}}$
by what has just been proved. Consequently, it would follow that the permutation τ coinciding with σ, except at j and n, where τ(j) = k and τ(n) = n, gives rise a better result. This contradicts the choice of σ. Hence σ(n) = n, and from the induction hypothesis, σ(i) = i for every i < n.

The same proof holds if one replace strict inequalities by non strict ones.

## Generalizations

A straightforward generalization takes into account more sequences. Assume we have ordered sequences of positive real numbers

${\displaystyle x_{n}\geq \cdots \geq x_{1}\geq 0\quad {\text{and}}\quad y_{n}\geq \cdots \geq y_{1}\geq 0\quad {\text{and}}\quad z_{n}\geq \cdots \geq z_{1}\geq 0}$
and a permutation ${\displaystyle x_{\sigma (1)},\dots ,x_{\sigma (n)}}$ of ${\displaystyle x_{1},\dots ,x_{n}}$ and another permutation ${\displaystyle y_{\tau (1)},\dots ,y_{\tau (n)}}$ of ${\displaystyle y_{1},\dots ,y_{n}}$. Then it holds
${\displaystyle x_{n}y_{n}z_{n}+\ldots +x_{1}y_{1}z_{1}\geq x_{\sigma (n)}y_{\tau (n)}z_{n}+\ldots +x_{\sigma (1)}y_{\tau (1)}z_{1}.}$

Note that unlike the common rearrangement inequality this statement requires the numbers to be nonnegative. A similar statement is true for any number of sequences with all numbers nonnegative.

Another generalization of the rearrangement inequality states that for all real numbers ${\displaystyle x_{1}\leq \cdots \leq x_{n}}$ and any choice of functions ${\displaystyle f_{i}:[x_{1},x_{n}]\rightarrow \mathbb {R} ,i=1,2,\ldots ,n}$ such that the derivatives ${\displaystyle f'_{i}}$ satisfy:

${\displaystyle f'_{1}(x)\leq f'_{2}(x)\leq \cdots \leq f'_{n}(x)\quad {\text{ for all }}x\in [x_{1},x_{n}]}$
the inequality
${\displaystyle \sum _{i=1}^{n}f_{i}(x_{n-i+1})\leq \sum _{i=1}^{n}f_{i}(x_{\sigma (i)})\leq \sum _{i=1}^{n}f_{i}(x_{i})}$
holds for every permutation ${\displaystyle x_{\sigma (1)},\ldots ,x_{\sigma (n)}}$ of ${\displaystyle x_{1},\ldots ,x_{n}.}$[2]