{
  "aliases": null,
  "backlinks": [
    {
      "field": "uses",
      "target": "8RDSR3JXP2"
    }
  ],
  "body": "\n## Statement\n\nLet $n \\ge 2$ and consider the [[linear system|0GT4WWGWH2]]\n$$a_i x_{i-1} + b_i x_i + c_i x_{i+1} = d_i, \\qquad i = 1, \\dots, n,$$\nwith real or complex coefficients, $a_1 = 0$ and $c_n = 0$, whose matrix $A$ is [[tridiagonal|DARX1KZRHZ]].\nAssume that $A$ is strictly [[diagonally dominant|89P5GTKW87]] by rows: $\\abs{b_i} \u003e \\abs{a_i} + \\abs{c_i}$ for all $i$.\nThe *tridiagonal matrix algorithm* (or *Thomas algorithm*) computes\n$$c'_1 = \\frac{c_1}{b_1}, \\quad d'_1 = \\frac{d_1}{b_1}, \\qquad c'_i = \\frac{c_i}{b_i - a_i c'_{i-1}}, \\quad d'_i = \\frac{d_i - a_i d'_{i-1}}{b_i - a_i c'_{i-1}} \\quad (i = 2, \\dots, n),$$\nand then\n$$x_n = d'_n, \\qquad x_i = d'_i - c'_i x_{i+1} \\quad (i = n - 1, \\dots, 1).$$\nThen every denominator $b_i - a_i c'_{i-1}$ is nonzero, $\\abs{c'_i} \u003c 1$ for all $i$, and $(x_1, \\dots, x_n)$ is the unique solution of the system.\nThe algorithm uses $O(n)$ arithmetic operations.\n\n## Remarks\n\nThe proof is an induction on $i$.\nIf $\\abs{c'_{i-1}} \u003c 1$, then $\\abs{b_i - a_i c'_{i-1}} \\ge \\abs{b_i} - \\abs{a_i} \u003e \\abs{c_i} \\ge 0$, so the denominator is nonzero and $\\abs{c'_i} \u003c 1$.\nThe forward sweep is [[Gaussian elimination|0JVJ2WCXZH]] without pivoting, which keeps the tridiagonal shape, and it computes the [[LU decomposition|0RKG5YW66Y]] of $A$ with bidiagonal factors; the second sweep is [[back substitution|0ATFVE08MW]].\nFor diagonally dominant or symmetric positive definite matrices, the algorithm is also numerically stable.\nWithout such a hypothesis a denominator can vanish even when $A$ is invertible: for $b_1 = 0$, $c_1 = 1$, $a_2 = 1$, $b_2 = 0$, the matrix $\\begin{pmatrix} 0 \u0026 1 \\\\ 1 \u0026 0 \\end{pmatrix}$ is invertible but the first step divides by $0$.\nExample: the system $2x_1 - x_2 = 1$, $-x_1 + 2x_2 = 1$ is diagonally dominant by rows; the algorithm gives $c'_1 = -1/2$, $d'_1 = 1/2$, $d'_2 = (1 + 1/2)/(2 - 1/2) = 1$, so $x_2 = 1$ and $x_1 = 1/2 + 1/2 = 1$.\n\n## Explanations\n\n### L1 human\n\nMany problems, such as heat flow along a rod or spline fitting, give systems where each equation involves only an unknown and its two neighbours.\nThe Thomas algorithm solves such a system in two sweeps: down the list, eliminating one unknown from each equation, and back up, reading off the unknowns one by one.\nThe work grows only in proportion to the number of unknowns, instead of its cube.\n\n### L2 human\n\nThe algorithm is Gaussian elimination specialized to tridiagonal matrices, with no fill-in and no pivoting.\nStrict diagonal dominance is a simple condition that guarantees it never divides by zero.\nThe finite difference matrix of $-u'' = f$, with rows $(-1, 2, -1)$, is only weakly diagonally dominant, but it is symmetric positive definite, and the algorithm works for it too.\nFor tridiagonal systems that are not diagonally dominant, one uses Gaussian elimination with partial pivoting on the band instead.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "DARX1KZRHZ",
      "0GT4WWGWH2"
    ],
    "kind": "statement",
    "msc": [
      "65F05"
    ],
    "name": "Tridiagonal matrix algorithm",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q1819156",
      "wikipedia": "Tridiagonal matrix algorithm"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm"
      }
    ],
    "tag": "F1QWA1PEQQ",
    "uses": [
      "DARX1KZRHZ",
      "89P5GTKW87",
      "0JVJ2WCXZH",
      "0RKG5YW66Y",
      "0ATFVE08MW",
      "0GT4WWGWH2"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/F1QWA1PEQQ/",
  "links": [
    {
      "field": "about",
      "target": "DARX1KZRHZ"
    },
    {
      "field": "about",
      "target": "0GT4WWGWH2"
    },
    {
      "field": "uses",
      "target": "DARX1KZRHZ"
    },
    {
      "field": "uses",
      "target": "89P5GTKW87"
    },
    {
      "field": "uses",
      "target": "0JVJ2WCXZH"
    },
    {
      "field": "uses",
      "target": "0RKG5YW66Y"
    },
    {
      "field": "uses",
      "target": "0ATFVE08MW"
    },
    {
      "field": "uses",
      "target": "0GT4WWGWH2"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/F1QWA1PEQQ.md",
  "msc": [
    "65F05"
  ],
  "name": "Tridiagonal matrix algorithm",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/F1Q/F1QWA1PEQQ.md",
  "status": null,
  "tag": "F1QWA1PEQQ",
  "uri": "m2://F1QWA1PEQQ",
  "url": "https://tamnd.github.io/math2/wiki/tridiagonal-matrix-algorithm/",
  "writing": {
    "tag": "F1QWA1PEQQ",
    "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
      }
    ]
  }
}
