{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $x_1 \\le x_2 \\le \\dots \\le x_n$ and $y_1 \\le y_2 \\le \\dots \\le y_n$ be real numbers, and let $\\sigma$ be a [[permutation|0BQMWCNS8S]] of $\\set{1, \\dots, n}$.\nThen\n$$\\sum_{i=1}^{n} x_i y_{n+1-i} \\le \\sum_{i=1}^{n} x_i y_{\\sigma(i)} \\le \\sum_{i=1}^{n} x_i y_i.$$\n\n## Remarks\n\nProof idea: suppose $i \u003c j$ but $y_{\\sigma(i)} \u003e y_{\\sigma(j)}$.\nSwapping the two values changes the sum by $(x_j - x_i)(y_{\\sigma(i)} - y_{\\sigma(j)}) \\ge 0$.\nRepeated swaps sort $\\sigma$ into the identity without decreasing the sum, which gives the upper bound.\nThe lower bound follows by applying the upper bound to $-y_n \\le \\dots \\le -y_1$.\n\nExample: with $x = (1, 2, 3)$ and $y = (4, 5, 6)$, the sums range from $1 \\cdot 6 + 2 \\cdot 5 + 3 \\cdot 4 = 28$ to $1 \\cdot 4 + 2 \\cdot 5 + 3 \\cdot 6 = 32$.\n\nMathlib states a form as `Monovary.sum_smul_comp_perm_le_sum_smul`.\n\n## Explanations\n\n### L1 human\n\nYou have $n$ boxes of banknotes and may take some number of notes from each box, with the counts given in advance.\nTo get the most money, take the most notes from the box with the largest bills.\nTo get the least, take the most notes from the box with the smallest bills.\nThe rearrangement inequality says exactly this: matching large with large maximises a sum of products.\n\n### L2 human\n\nThe rearrangement inequality gives quick proofs of several classical inequalities.\nAveraging it over the cyclic shifts of $y$ gives [[Chebyshev's sum inequality|S8X2N1DW8P]].\nApplied to suitable sequences it also gives the [[AM–GM inequality|0DRF0F3XC9]] and the [[Cauchy–Schwarz inequality|0RFWW56Y22]] in special cases.\n",
  "commit": "efe85cee8dbc57d85bedbacfb97b99d1b7bee843",
  "front": {
    "about": [
      "0BQMWCNS8S"
    ],
    "kind": "statement",
    "msc": [
      "26D15"
    ],
    "name": "Rearrangement inequality",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q1149189",
      "wikipedia": "Rearrangement inequality"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Rearrangement_inequality"
      }
    ],
    "tag": "6E9TAF8HCY",
    "uses": [
      "0BQMWCNS8S"
    ]
  },
  "kind": "statement",
  "link": "https://math2.tamnd.com/node/6E9TAF8HCY/",
  "links": [
    {
      "field": "about",
      "target": "0BQMWCNS8S"
    },
    {
      "field": "uses",
      "target": "0BQMWCNS8S"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/6E9TAF8HCY.md",
  "msc": [
    "26D15"
  ],
  "name": "Rearrangement inequality",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/6E9/6E9TAF8HCY.md",
  "status": null,
  "tag": "6E9TAF8HCY",
  "uri": "m2://6E9TAF8HCY",
  "url": "https://math2.tamnd.com/wiki/rearrangement-inequality/",
  "writing": {
    "tag": "6E9TAF8HCY",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
