{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $h \u003e 0$ be a grid spacing.\n\n1. In one dimension, the *five-point stencil* at $x \\in \\R$ is the set of points $x - 2h, x - h, x, x + h, x + 2h$.\nThe associated formulas for a function $f$ are\n$$f'(x) \\approx \\frac{-f(x + 2h) + 8 f(x + h) - 8 f(x - h) + f(x - 2h)}{12 h},$$\n$$f''(x) \\approx \\frac{-f(x + 2h) + 16 f(x + h) - 30 f(x) + 16 f(x - h) - f(x - 2h)}{12 h^2}.$$\n2. In two dimensions, the *five-point stencil* at $(x, y) \\in \\R^2$ is the set of points $(x, y)$, $(x \\pm h, y)$, $(x, y \\pm h)$.\nThe associated *five-point Laplacian* of a function $u$ is\n$$\\Delta_h u(x, y) = \\frac{u(x + h, y) + u(x - h, y) + u(x, y + h) + u(x, y - h) - 4 u(x, y)}{h^2}.$$\n\n## Remarks\n\nThe one-dimensional weights are the [[finite difference coefficients|752Z7DRT7P]] for the stencil $-2, -1, 0, 1, 2$.\nFor $f \\in C^5$, the first formula has error $-\\frac{h^4}{30} f^{(5)}(\\xi)$ for some $\\xi$ in $(x - 2h, x + 2h)$, so it has order $4$; the second has order $4$ for $f \\in C^6$.\nCheck of the second formula on $f(s) = s^2$ at $x = 0$: $\\frac{-4h^2 + 16h^2 + 16h^2 - 4h^2}{12h^2} = 2 = f''(0)$.\nFor $u \\in C^4$, each one-dimensional second difference has error $\\frac{h^2}{12} \\partial^4 u$ at an intermediate point, so $\\abs{\\Delta_h u - \\Delta u} \\le \\frac{h^2}{12} \\big( \\max \\abs{u_{xxxx}} + \\max \\abs{u_{yyyy}} \\big)$ and the five-point Laplacian approximates the [[Laplacian|0E0B6RA8K0]] to second order.\nNon-example: the nine-point and the diagonal five-point stencil $(x \\pm h, y \\pm h)$ also approximate $\\Delta u$, the latter as $\\frac{1}{2h^2}\\big(\\sum u(x \\pm h, y \\pm h) - 4u(x,y)\\big)$, but it uses different points and is not the five-point stencil defined here.\n\n## Explanations\n\n### L1 human\n\nIn one dimension, the five-point stencil uses two points on each side of $x$ and gives very accurate derivative estimates.\nIn two dimensions, it uses the four neighbours of a grid point and estimates the Laplacian, which measures how a value differs from the average of its surroundings.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "73WPYFAEWS",
    "kind": "definition",
    "msc": [
      "65N06",
      "65D25"
    ],
    "name": "Five-point stencil",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Five-point_stencil"
      }
    ],
    "tag": "DHRDTHFBFA",
    "uses": [
      "752Z7DRT7P",
      "0E0B6RA8K0"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/DHRDTHFBFA/",
  "links": [
    {
      "field": "defines",
      "target": "73WPYFAEWS"
    },
    {
      "field": "uses",
      "target": "752Z7DRT7P"
    },
    {
      "field": "uses",
      "target": "0E0B6RA8K0"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/DHRDTHFBFA.md",
  "msc": [
    "65N06",
    "65D25"
  ],
  "name": "Five-point stencil",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/DHR/DHRDTHFBFA.md",
  "status": null,
  "tag": "DHRDTHFBFA",
  "uri": "m2://DHRDTHFBFA",
  "url": "https://tamnd.github.io/math2/wiki/five-point-stencil-definition/",
  "writing": {
    "tag": "DHRDTHFBFA",
    "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
      }
    ]
  }
}
