{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $f \\colon \\R^m \\to \\R^m$ be smooth, and consider the [[conservation law|8RA7AMWSAF]] $u_t + f(u)_x = 0$.\nFix $\\Delta x \u003e 0$ and $\\Delta t \u003e 0$, put $\\lambda = \\Delta t / \\Delta x$, and let $u_j^n$ approximate $u(j \\Delta x, n \\Delta t)$.\nThe *MacCormack method* computes $u^{n+1}$ from $u^n$ in two steps.\n\n1. Predictor, with a forward difference: $u_j^{*} = u_j^n - \\lambda \\left( f(u_{j+1}^n) - f(u_j^n) \\right)$.\n2. Corrector, with a backward difference: $u_j^{n+1} = \\frac12 \\left( u_j^n + u_j^{*} \\right) - \\frac{\\lambda}{2} \\left( f(u_j^{*}) - f(u_{j-1}^{*}) \\right)$.\n\n## Remarks\n\nExample: for $f(u) = a u$ and $\\nu = a \\lambda$, the predictor gives $u_j^* - u_{j-1}^* = (u_j^n - u_{j-1}^n) - \\nu (u_{j+1}^n - 2u_j^n + u_{j-1}^n)$.\nPutting this into the corrector gives\n$$u_j^{n+1} = u_j^n - \\frac{\\nu}{2} (u_{j+1}^n - u_{j-1}^n) + \\frac{\\nu^2}{2} (u_{j+1}^n - 2u_j^n + u_{j-1}^n),$$\nwhich is the [[Lax–Wendroff method|YHZ9BCNDRZ]]; so the method is second-order accurate and stable for $\\abs{\\nu} \\le 1$ in this case.\nNon-example: using a forward difference in the corrector as well gives, for $f(u) = a u$, the scheme $u_j^{n+1} = u_j^n - \\nu (u_{j+1}^n - u_j^n) + \\frac{\\nu^2}{2}(u_{j+2}^n - 2u_{j+1}^n + u_j^n)$, whose Taylor expansion leaves the error term $-\\frac{a \\Delta x}{2} u_{xx}$, so it is only first order.\nThe order of the one-sided differences may be reversed (backward in the predictor, forward in the corrector); alternating the two orders from step to step is common.\n\n## Explanations\n\n### L1 human\n\nPredict with differences pointing forward, correct with differences pointing back, and average.\nFor linear problems this is exactly the Lax–Wendroff scheme.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "PGXZJ2YWVJ",
    "kind": "definition",
    "msc": [
      "65M06",
      "35L65"
    ],
    "name": "MacCormack method",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/MacCormack_method"
      }
    ],
    "tag": "5R9ZRK8YB5",
    "uses": [
      "8RA7AMWSAF",
      "X7HYEBA5SA",
      "YHZ9BCNDRZ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/5R9ZRK8YB5/",
  "links": [
    {
      "field": "defines",
      "target": "PGXZJ2YWVJ"
    },
    {
      "field": "uses",
      "target": "8RA7AMWSAF"
    },
    {
      "field": "uses",
      "target": "X7HYEBA5SA"
    },
    {
      "field": "uses",
      "target": "YHZ9BCNDRZ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/5R9ZRK8YB5.md",
  "msc": [
    "65M06",
    "35L65"
  ],
  "name": "MacCormack method",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/5R9/5R9ZRK8YB5.md",
  "status": null,
  "tag": "5R9ZRK8YB5",
  "uri": "m2://5R9ZRK8YB5",
  "url": "https://tamnd.github.io/math2/wiki/maccormack-method-definition/",
  "writing": {
    "tag": "5R9ZRK8YB5",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
