{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $\\F_q$ be the [[finite field|08RTDHX1SK]] with $q$ elements and let $f \\in \\F_q[x]$ be a [[monic|0BDX4MBKT4]] square-free polynomial of degree $n \\ge 1$.\nLet $V$ be the $\\F_q$-vector space of polynomials of degree less than $n$.\nThe Berlekamp subalgebra of $f$ is\n$$B = \\set{g \\in V : g^q \\equiv g \\pmod{f}}.$$\nBerlekamp's algorithm factors $f$ as follows.\n\n1. Compute the matrix $Q$ of the $\\F_q$-linear map $V \\to V$, $h \\mapsto h^q \\bmod f$, and a basis of $B$ as the [[null space|0PQ2GGY1QV]] of $Q - I$.\n2. If $\\dim B = 1$, then $f$ is irreducible.\n3. Otherwise take $g \\in B$ of positive degree; then $f = \\prod_{s \\in \\F_q} \\gcd(f, g - s)$, and at least two of these factors have positive degree.\n4. Apply step 3 to the factors, with other elements of $B$, until there are $\\dim B$ factors.\n\n## Remarks\n\nBy the [[Chinese remainder theorem|0W97J8QED7]], $B \\cong \\F_q^k$, where $k$ is the number of irreducible factors of $f$, so $\\dim B = k$.\nStep 3 holds because $g^q - g = \\prod_{s \\in \\F_q} (g - s)$ and $f$ divides $g^q - g$; the factors $g - s$ are pairwise coprime, and none of them is divisible by $f$.\nExample: $f = x^2 + 1$ over $\\F_5$; since $x^5 \\equiv x \\pmod{f}$, $B = V$ has dimension $2$, and $g = x$ gives $\\gcd(f, x - 2) = x - 2$ and $\\gcd(f, x - 3) = x - 3$.\nNon-example: $f = x^2 + 1$ over $\\F_3$; since $x^3 \\equiv -x \\pmod{f}$, $(a + bx)^3 \\equiv a - bx$, so $B$ is the constants, $\\dim B = 1$, and $f$ is irreducible.\nThe algorithm needs $f$ square-free; a repeated factor is first removed with $\\gcd(f, f')$.\nThe running time is polynomial in $n$ and $q$, so it suits small fields; for large $q$ randomised variants are used.\n\n## Explanations\n\n### L1 human\n\nThe algorithm computes the $q$-th power map on remainders modulo $f$ and finds its fixed points by Gaussian elimination.\nEach fixed point that is not a constant lets one split $f$ with greatest common divisors.\n",
  "commit": "5fc425f97f1f6b11da5892c2948ef8c5d8805665",
  "front": {
    "defines": "EM8MFGFAGN",
    "kind": "definition",
    "msc": [
      "11T06",
      "11Y16",
      "68W30"
    ],
    "name": "Berlekamp's algorithm",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Berlekamp%27s_algorithm"
      }
    ],
    "tag": "HJW1KSQZWA",
    "uses": [
      "08RTDHX1SK",
      "0BDX4MBKT4",
      "99J1WXG3F7",
      "0PQ2GGY1QV",
      "0W97J8QED7"
    ]
  },
  "kind": "definition",
  "link": "https://math2.tamnd.com/node/HJW1KSQZWA/",
  "links": [
    {
      "field": "defines",
      "target": "EM8MFGFAGN"
    },
    {
      "field": "uses",
      "target": "08RTDHX1SK"
    },
    {
      "field": "uses",
      "target": "0BDX4MBKT4"
    },
    {
      "field": "uses",
      "target": "99J1WXG3F7"
    },
    {
      "field": "uses",
      "target": "0PQ2GGY1QV"
    },
    {
      "field": "uses",
      "target": "0W97J8QED7"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/HJW1KSQZWA.md",
  "msc": [
    "11T06",
    "11Y16",
    "68W30"
  ],
  "name": "Berlekamp's algorithm",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/HJW/HJW1KSQZWA.md",
  "status": null,
  "tag": "HJW1KSQZWA",
  "uri": "m2://HJW1KSQZWA",
  "url": "https://math2.tamnd.com/wiki/berlekamps-algorithm-definition/",
  "writing": {
    "tag": "HJW1KSQZWA",
    "kind": "definition",
    "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
      }
    ]
  }
}
