{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $m \\ge 0$ and $N \\ge m + 1$ be integers, and let $s_1, \\ldots, s_N$ be distinct real numbers, the *stencil*.\nThe *finite difference coefficients* for the $m$-th derivative on this stencil are the real numbers $a_1, \\ldots, a_N$ that solve\n$$\\sum_{j=1}^{N} a_j \\, s_j^{\\,i} = \\begin{cases} m! \u0026 \\text{if } i = m, \\\\ 0 \u0026 \\text{if } i \\ne m, \\end{cases} \\qquad i = 0, 1, \\ldots, N - 1.$$\nThe associated formula is $f^{(m)}(x) \\approx h^{-m} \\sum_{j=1}^{N} a_j f(x + s_j h)$ for a step $h \u003e 0$.\n\n## Remarks\n\nThe matrix of the system is a [[Vandermonde matrix|Q3JWBZ7EFY]] in the distinct numbers $s_j$, so the coefficients exist and are unique.\nExpanding $f(x + s_j h)$ by [[Taylor's theorem|03QHBVW4TT]] up to order $N - 1$ shows that for $f \\in C^N$ the formula has error $O(h^{N - m})$; for symmetric stencils the order is often one higher.\nExample: $m = 1$ and the forward stencil $0, 1, 2$ give $a = (-\\tfrac32, 2, -\\tfrac12)$.\nCheck: $\\sum a_j = 0$, $\\sum a_j s_j = 2 - 1 = 1 = 1!$, and $\\sum a_j s_j^2 = 2 - 2 = 0$.\nSo $f'(x) \\approx \\frac{-3 f(x) + 4 f(x+h) - f(x+2h)}{2h}$, with error $O(h^2)$.\nNon-example: for $m = 2$ the weights $(1, -2, 1)$ on the stencil $0, 1, 3$ are not the coefficients, since $\\sum a_j s_j = -2 + 3 = 1 \\ne 0$; the correct ones there are $(\\tfrac23, -1, \\tfrac13)$.\n\n## Explanations\n\n### L1 human\n\nThe weighted sum of the samples cancels every term of the Taylor expansion except the wanted derivative.\nIt does so up to the degree that the number of points allows.\nMore points give more cancellations and a more accurate formula.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "752Z7DRT7P",
    "kind": "definition",
    "msc": [
      "65D25",
      "65N06"
    ],
    "name": "Finite difference coefficients",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Finite_difference_coefficient"
      }
    ],
    "tag": "QE16SFY3GR",
    "uses": [
      "NVH3F8FTYS",
      "Q3JWBZ7EFY",
      "03QHBVW4TT"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/QE16SFY3GR/",
  "links": [
    {
      "field": "defines",
      "target": "752Z7DRT7P"
    },
    {
      "field": "uses",
      "target": "NVH3F8FTYS"
    },
    {
      "field": "uses",
      "target": "Q3JWBZ7EFY"
    },
    {
      "field": "uses",
      "target": "03QHBVW4TT"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/QE16SFY3GR.md",
  "msc": [
    "65D25",
    "65N06"
  ],
  "name": "Finite difference coefficients",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/QE1/QE16SFY3GR.md",
  "status": null,
  "tag": "QE16SFY3GR",
  "uri": "m2://QE16SFY3GR",
  "url": "https://tamnd.github.io/math2/wiki/finite-difference-coefficients-definition/",
  "writing": {
    "tag": "QE16SFY3GR",
    "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
      }
    ]
  }
}
