{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $n \\ge 0$, let $x_0, x_1, \\dots, x_n$ be pairwise distinct real numbers, and let $y_0, y_1, \\dots, y_n$ be real numbers.\nFor $j = 0, \\dots, n$, the *Lagrange basis polynomial* is\n$$\\ell_j(x) = \\prod_{\\substack{0 \\le m \\le n \\\\ m \\ne j}} \\frac{x - x_m}{x_j - x_m}.$$\nThe *Lagrange polynomial* of the data $(x_j, y_j)$ is\n$$L(x) = \\sum_{j=0}^{n} y_j \\, \\ell_j(x).$$\n\n## Remarks\n\nEach $\\ell_j$ has [[degree|0DPF6WRZW6]] $n$, with $\\ell_j(x_j) = 1$ and $\\ell_j(x_k) = 0$ for $k \\ne j$.\nSo $L$ lies in the [[polynomial ring|0Q9EZS90GY]] $\\R[x]$, has degree at most $n$, and satisfies $L(x_k) = y_k$ for all $k$.\nIt is the unique polynomial with these properties: the difference of two of them has degree at most $n$ and $n + 1$ roots, so it is $0$.\nThe same formula works over any field; this solves [[polynomial interpolation|SS1YMS2NPC]].\n\nExample: nodes $0, 1, 2$ with values $1, 3, 7$.\nHere $\\ell_0 = \\frac{(x - 1)(x - 2)}{2}$, $\\ell_1 = -x(x - 2)$ and $\\ell_2 = \\frac{x(x - 1)}{2}$.\nThen $L = \\ell_0 + 3 \\ell_1 + 7 \\ell_2 = x^2 + x + 1$, and indeed $L(0) = 1$, $L(1) = 3$, $L(2) = 7$.\n\nNon-example: if two nodes coincide, say $x_0 = x_1$, the factor $\\frac{x - x_1}{x_0 - x_1}$ in $\\ell_0$ has denominator $0$, so the formula is not defined.\n",
  "commit": "5fc425f97f1f6b11da5892c2948ef8c5d8805665",
  "front": {
    "defines": "Y7KSGE97GK",
    "kind": "definition",
    "msc": [
      "41A05",
      "65D05",
      "26C05"
    ],
    "name": "Lagrange polynomial",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Lagrange_polynomial"
      }
    ],
    "tag": "TEQNAME853",
    "uses": [
      "0Q9EZS90GY",
      "0DPF6WRZW6",
      "SS1YMS2NPC"
    ]
  },
  "kind": "definition",
  "link": "https://math2.tamnd.com/node/TEQNAME853/",
  "links": [
    {
      "field": "defines",
      "target": "Y7KSGE97GK"
    },
    {
      "field": "uses",
      "target": "0Q9EZS90GY"
    },
    {
      "field": "uses",
      "target": "0DPF6WRZW6"
    },
    {
      "field": "uses",
      "target": "SS1YMS2NPC"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/TEQNAME853.md",
  "msc": [
    "41A05",
    "65D05",
    "26C05"
  ],
  "name": "Lagrange polynomial",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/TEQ/TEQNAME853.md",
  "status": null,
  "tag": "TEQNAME853",
  "uri": "m2://TEQNAME853",
  "url": "https://math2.tamnd.com/wiki/lagrange-polynomial-definition/",
  "writing": {
    "tag": "TEQNAME853",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
