{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $R$ be an [[integral domain|0QVD7WBFGN]] and let $A = (a_{ij})$ be an $n \\times n$ matrix over $R$, with $n \\ge 2$.\nPut $a^{(0)}_{ij} = a_{ij}$.\nFor $k = 1, \\dots, n - 1$ and $k \u003c i, j \\le n$, the *Bareiss algorithm* sets\n$$a^{(k)}_{ij} = \\frac{a^{(k-1)}_{kk} \\, a^{(k-1)}_{ij} - a^{(k-1)}_{ik} \\, a^{(k-1)}_{kj}}{a^{(k-2)}_{k-1, k-1}},$$\nwhere the denominator is $1$ for $k = 1$.\nAssume that the leading principal [[minors|0BT9BYWVRY]] of $A$ of orders $1, \\dots, n - 1$ are nonzero.\nThen:\n\n1. for each $k$ and each $i, j \u003e k$, the entry $a^{(k)}_{ij}$ equals the determinant of the $(k+1) \\times (k+1)$ submatrix of $A$ with rows $1, \\dots, k, i$ and columns $1, \\dots, k, j$;\n2. in particular, every division in the algorithm is exact in $R$, every pivot $a^{(k-1)}_{kk}$ is the leading principal minor of order $k$, and $a^{(n-1)}_{nn} = \\det A$.\n\n## Remarks\n\nClause 1 is proved by induction on $k$ with Sylvester's determinant identity, which expresses a bordered minor of the reduced matrix as a ratio of minors of $A$.\nFor $k = 1$ it is the direct check $a^{(1)}_{ij} = a_{11} a_{ij} - a_{i1} a_{1j} = \\det \\begin{pmatrix} a_{11} \u0026 a_{1j} \\\\ a_{i1} \u0026 a_{ij} \\end{pmatrix}$.\nExample: for $A = \\begin{pmatrix} 2 \u0026 3 \u0026 1 \\\\ 4 \u0026 1 \u0026 5 \\\\ 6 \u0026 2 \u0026 3 \\end{pmatrix}$ over $\\Z$, step $1$ gives $a^{(1)}_{22} = -10$, $a^{(1)}_{23} = 6$, $a^{(1)}_{32} = -14$, $a^{(1)}_{33} = 0$, and step $2$ gives $a^{(2)}_{33} = \\big((-10) \\cdot 0 - 6 \\cdot (-14)\\big)/2 = 42 = \\det A$.\nOver $\\Z$, clause 1 and [[Hadamard's inequality|CGDN1X32NQ]] bound the size of every intermediate entry.\nSo the bit length of the numbers grows only polynomially, unlike naive fraction-free elimination, where it can double at each step.\nIf a pivot is zero, rows can be exchanged as in [[Gaussian elimination|0JVJ2WCXZH]], which changes the sign of the [[determinant|00KDZRW4C0]].\nThe algorithm uses $O(n^3)$ operations in $R$.\n\n## Explanations\n\n### L1 human\n\nTo compute a determinant of an integer matrix exactly, one wants to avoid fractions.\nCross-multiplying rows avoids fractions but makes the numbers huge.\nThe Bareiss algorithm cross-multiplies and then divides by the previous pivot, and a theorem guarantees that this division always leaves no remainder.\n\n### L2 human\n\nIt is fraction-free Gaussian elimination: the work is the same order as ordinary elimination, but all intermediate values are minors of the input matrix.\nIt is a standard method in computer algebra for determinants, ranks and exact solutions of linear systems over $\\Z$ or over polynomial rings.\nThe final pivot is the determinant, and the earlier pivots are the leading principal minors.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "00KDZRW4C0"
    ],
    "kind": "statement",
    "msc": [
      "65F40",
      "15A15",
      "68W30"
    ],
    "name": "Bareiss algorithm",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q4860404",
      "wikipedia": "Bareiss algorithm"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Bareiss_algorithm"
      }
    ],
    "tag": "ZDBW3AB587",
    "uses": [
      "00KDZRW4C0",
      "0BT9BYWVRY",
      "0QVD7WBFGN",
      "0JVJ2WCXZH",
      "CGDN1X32NQ"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/ZDBW3AB587/",
  "links": [
    {
      "field": "about",
      "target": "00KDZRW4C0"
    },
    {
      "field": "uses",
      "target": "00KDZRW4C0"
    },
    {
      "field": "uses",
      "target": "0BT9BYWVRY"
    },
    {
      "field": "uses",
      "target": "0QVD7WBFGN"
    },
    {
      "field": "uses",
      "target": "0JVJ2WCXZH"
    },
    {
      "field": "uses",
      "target": "CGDN1X32NQ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/ZDBW3AB587.md",
  "msc": [
    "65F40",
    "15A15",
    "68W30"
  ],
  "name": "Bareiss algorithm",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/ZDB/ZDBW3AB587.md",
  "status": null,
  "tag": "ZDBW3AB587",
  "uri": "m2://ZDBW3AB587",
  "url": "https://tamnd.github.io/math2/wiki/bareiss-algorithm/",
  "writing": {
    "tag": "ZDBW3AB587",
    "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
      }
    ]
  }
}
