{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $n \\ge 1$ be an integer, and let $r_4(n)$ be the number of quadruples $(a, b, c, d)$ of [[integers|0C4JS9RF5M]] with $a^2 + b^2 + c^2 + d^2 = n$.\nThen\n$$r_4(n) = 8 \\sum_{\\substack{d \\mid n \\\\ 4 \\nmid d}} d.$$\nLet $\\sigma$ be the [[sum of divisors|06TK51263Q]], and let $m$ be the largest odd divisor of $n$.\nEquivalently, $r_4(n) = 8\\sigma(n)$ if $n$ is odd, and $r_4(n) = 24\\sigma(m)$ if $n$ is even.\n\n## Remarks\n\nOne proof uses the series $\\sum_{n \\in \\Z} q^{n^2}$ with $q = e^{2 \\pi i \\tau}$, which is $\\theta(2\\tau)$ for the theta constant $\\theta$ of the [[theta function|2F5CYQJVAF]].\nIts fourth power is $\\sum_{n \\ge 0} r_4(n) q^n$.\nThe function $\\theta(2\\tau)^4$ is a [[modular form|GWKN5VG78A]] of weight $2$ for the [[congruence subgroup|1H6R856P3C]] $\\Gamma_0(4)$.\nThat space has dimension $2$ and is spanned by Eisenstein series, and comparing two coefficients gives the formula.\nElementary proofs also exist.\nExample: $n = 4$ has divisors $1, 2$ not divisible by $4$, so $r_4(4) = 8 \\cdot 3 = 24$.\nCheck: the solutions are the $8$ quadruples with one entry $\\pm 2$ and three zeros, and the $16$ quadruples with all entries $\\pm 1$.\nSince the sum always contains $d = 1$, $r_4(n) \\ge 8 \u003e 0$, which gives [[Lagrange's four-square theorem|0KYYSMEVHH]].\n\n## Explanations\n\n### L1 human\n\nEvery positive integer is a sum of four squares, and this theorem says exactly in how many ways.\nThe count is $8$ times the sum of the divisors of $n$ that are not multiples of $4$.\nOrder and signs count: $1 = 1^2 + 0^2 + 0^2 + 0^2$ gives $8$ representations, one for each position and sign.\nIt turns an existence result into an exact formula.\n\n### L2 human\n\nThe theorem is a model case of how modular forms solve counting problems.\nA generating function of a counting problem is shown to be modular, and the finite dimension of the space of modular forms identifies it.\nFor two squares the same method gives $r_2(n) = 4 \\sum_{d \\mid n,\\, d \\text{ odd}} \\chi(d)$, where $\\chi(d) = (-1)^{(d-1)/2}$.\nFor larger numbers of squares, cusp forms can appear, and the exact formula then has a cusp form term besides the divisor sums.\n",
  "commit": "efe85cee8dbc57d85bedbacfb97b99d1b7bee843",
  "front": {
    "about": [
      "04J4Z73J5B"
    ],
    "kind": "statement",
    "msc": [
      "11E25",
      "11F27"
    ],
    "name": "Jacobi's four-square theorem",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q3527095",
      "wikipedia": "Jacobi's four-square theorem"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Jacobi%27s_four-square_theorem"
      }
    ],
    "tag": "CG17WSS64W",
    "uses": [
      "0C4JS9RF5M",
      "04J4Z73J5B",
      "06TK51263Q",
      "2F5CYQJVAF",
      "GWKN5VG78A",
      "1H6R856P3C"
    ]
  },
  "kind": "statement",
  "link": "https://math2.tamnd.com/node/CG17WSS64W/",
  "links": [
    {
      "field": "about",
      "target": "04J4Z73J5B"
    },
    {
      "field": "uses",
      "target": "0C4JS9RF5M"
    },
    {
      "field": "uses",
      "target": "04J4Z73J5B"
    },
    {
      "field": "uses",
      "target": "06TK51263Q"
    },
    {
      "field": "uses",
      "target": "2F5CYQJVAF"
    },
    {
      "field": "uses",
      "target": "GWKN5VG78A"
    },
    {
      "field": "uses",
      "target": "1H6R856P3C"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/CG17WSS64W.md",
  "msc": [
    "11E25",
    "11F27"
  ],
  "name": "Jacobi's four-square theorem",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/CG1/CG17WSS64W.md",
  "status": null,
  "tag": "CG17WSS64W",
  "uri": "m2://CG17WSS64W",
  "url": "https://math2.tamnd.com/wiki/jacobis-four-square-theorem/",
  "writing": {
    "tag": "CG17WSS64W",
    "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
      }
    ]
  }
}
