The Rearrangement Inequality: Why Order Matters

Suppose three workers have different levels of productivity and three tasks offer different rewards per unit of work. Should the most productive worker receive the most valuable task, or would a different assignment produce a larger total reward? A classical result called the rearrangement inequality answers this question—and many others—without checking every possible assignment.

1. A Puzzle About Pairing Numbers

Consider the numbers 2, 5, 9 and the numbers 1, 4, 7. Pair them in the same increasing order:

2\cdot1+5\cdot4+9\cdot7=85.

Pair them in opposite order:

2\cdot7+5\cdot4+9\cdot1=43.

Other pairings give values between these extremes. For example,

2\cdot4+5\cdot7+9\cdot1=52.

Why is the first arrangement largest and the second smallest? The answer comes from examining what happens when we swap two partners.

2. The Two-Pair Exchange

Suppose a\leq b and c\leq d. Compare pairing small with small and large with large against pairing small with large:

(ac+bd)-(ad+bc)=(b-a)(d-c)\geq0.

Therefore,

ac+bd\geq ad+bc.

The difference is exactly the product of the two gaps. If both gaps are positive, matching the larger numbers gives a strictly larger sum. This elementary observation is the engine behind the general theorem.

3. The Rearrangement Inequality

Theorem. Let two real sequences be arranged in nondecreasing order:

a_1\leq a_2\leq\cdots\leq a_n,\qquad b_1\leq b_2\leq\cdots\leq b_n.

For every permutation \pi of 1,2,\ldots,n,

\sum_{i=1}^n a_i b_{n+1-i}\ \leq\ \sum_{i=1}^n a_i b_{\pi(i)}\ \leq\ \sum_{i=1}^n a_i b_i.

Thus the sum of products is maximized by matching the same order and minimized by matching opposite orders. The result holds for negative as well as positive numbers.

If both sequences are strictly increasing, the maximizing permutation is unique (the same-order pairing), and the minimizing permutation is unique (the reverse pairing). When values repeat, different permutations can produce the same extreme sum.

4. Proof by Removing Inversions

Start with any pairing. If two positions i\lt j have their assigned b-values in the wrong order, write those assigned values as u\gt v. Before swapping, the two terms contribute

a_i u+a_j v.

After swapping, they contribute

a_i v+a_j u.

The change is

(a_j-a_i)(u-v)\geq0.

So removing an inversion never decreases the sum. Repeatedly removing inversions eventually puts the b-values in increasing order, producing the largest possible sum.

To obtain the smallest sum, apply the same argument to the numbers -b_i, or reverse the logic: matching the b-values in decreasing order produces the minimum. This proves both inequalities.

Equality: A swap changes nothing if either of the two a-values or the two assigned b-values are equal. Consequently, repeated values can create multiple maximizing or minimizing assignments.

5. Application: Assigning Workers to Tasks

Suppose three workers complete 2, 4, and 7 units of work per hour, while three tasks generate 3, 5, and 8 dollars per unit. If each worker is assigned one task, the greatest hourly reward is

2\cdot3+4\cdot5+7\cdot8=82.

The smallest reward is

2\cdot8+4\cdot5+7\cdot3=57.

There are six possible assignments, but the rearrangement inequality identifies the optimal and least favorable assignments immediately.

This model assumes the reward from assigning worker i to task j is exactly the product of that worker’s productivity and that task’s reward rate. More complicated assignment problems may require other optimization methods.

6. A Surprising Consequence: The Sum of Squared Differences

Let x_1\leq\cdots\leq x_n. Which permutation of these numbers makes

\sum_{i=1}^n (x_i-x_{\pi(i)})^2

as small or as large as possible?

Expand:

\sum_{i=1}^n(x_i-x_{\pi(i)})^2=2\sum_{i=1}^n x_i^2-2\sum_{i=1}^n x_i x_{\pi(i)}.

The first term is independent of the permutation. Therefore, minimizing the squared differences is equivalent to maximizing the sum of products. The rearrangement inequality tells us that matching each number with itself gives the minimum, which is zero. Reversing the order gives the maximum:

\max_{\pi}\sum_{i=1}^n(x_i-x_{\pi(i)})^2=\sum_{i=1}^n(x_i-x_{n+1-i})^2.

This connection illustrates how a problem about distances can become a problem about products.

7. Beyond Two Lists

The rearrangement inequality is particularly powerful because it reduces an optimization over n! possible pairings to a simple sorting rule. Its assumptions matter: we are pairing two fixed lists, each element is used exactly once, and the objective is a sum of pairwise products.

Related ideas appear in optimal matching, probability (comparing positively and negatively associated variables), and inequalities involving ordered sequences. But for more general costs, the best assignment need not come from sorting alone.

For a complementary inequality involving products and powers, see our article on Young’s Inequality: An Inequality Hidden in Areas. The two results solve different kinds of estimation problems: Young’s inequality bounds a product, while rearrangement tells us how to pair many products optimally.

8. Try It Yourself

Problem 1. Find the largest and smallest possible values of 1x+3y+6z, where x,y,z are the numbers 2, 4, and 9 in some order.

Solution. Pairing in the same order gives the maximum:

1\cdot2+3\cdot4+6\cdot9=68.

Reversing the order gives the minimum:

1\cdot9+3\cdot4+6\cdot2=33.

Problem 2. Does the rearrangement inequality still hold when some numbers are negative?

Solution. Yes. The exchange identity (b-a)(d-c)\geq0 depends only on the ordering, not on whether the numbers are positive. For example, with (-3,1) and (-2,4), the same-order sum is (-3)(-2)+1\cdot4=10, while the opposite-order sum is (-3)\cdot4+1\cdot(-2)=-14.

Problem 3. Explain why the maximum may be achieved by several permutations when numbers repeat.

Solution. Consider (a_1,a_2,a_3)=(1,1,3) and (b_1,b_2,b_3)=(2,4,5). Pairing 2 and 4 with the two equal coefficients 1 in either order gives the same maximum, 1\cdot2+1\cdot4+3\cdot5=21. Swapping partners at equal coefficients does not change the sum.

Problem 4. For the numbers 1, 2, 5, compute the maximum possible sum of squared differences between the list and a permutation of itself.

Solution. Reverse the list to obtain (5,2,1). The maximum is

(1-5)^2+(2-2)^2+(5-1)^2=32.

9. Final Thought

The rearrangement inequality shows that order can matter more than computation. Once we recognize the exchange principle, we no longer need to test every permutation: sorting reveals the extremes. This simple observation is a useful model for much broader optimization arguments.

References

  1. G. H. Hardy, J. E. Littlewood, and G. Pólya, Inequalities, 2nd ed., Cambridge University Press, 1952. See the discussion of the rearrangement inequality.
  2. A. W. Marshall, I. Olkin, and B. C. Arnold, Inequalities: Theory of Majorization and Its Applications, 2nd ed., Springer, 2011. For further connections to ordered vectors and majorization.

Another fundamental inequality involving sums of products is the Cauchy–Schwarz inequality. Unlike the rearrangement inequality, which compares different pairings, Cauchy–Schwarz provides a bound based on the magnitudes of the two sequences.

Leave a Reply

Your email address will not be published. Required fields are marked *