{
  "aliases": null,
  "backlinks": [
    {
      "field": "uses",
      "target": "8RDSR3JXP2"
    }
  ],
  "body": "\n## Statement\n\nLet $\\kappa \u003e 0$ and consider the [[heat equation|VP2HN86VAG]] $u_t = \\kappa u_{xx}$ on $0 \u003c x \u003c 1$, $t \u003e 0$, with $u(0, t) = u(1, t) = 0$ and a given initial value $u(x, 0)$.\nLet $M \\ge 1$, $\\Delta x = 1/(M + 1)$, $x_j = j \\Delta x$, $\\Delta t \u003e 0$, $t_n = n \\Delta t$ and $r = \\kappa \\Delta t / \\Delta x^2$.\nFor a grid vector $v = (v_0, \\ldots, v_{M+1})$ with $v_0 = v_{M+1} = 0$, put $(\\delta^2 v)_j = (v_{j+1} - 2 v_j + v_{j-1}) / \\Delta x^2$.\nThe Crank–Nicolson method computes $u^{n+1}$ from $u^n$ by\n$$\\frac{u_j^{n+1} - u_j^n}{\\Delta t} = \\frac{\\kappa}{2} \\left( (\\delta^2 u^{n+1})_j + (\\delta^2 u^n)_j \\right), \\qquad 1 \\le j \\le M.$$\n\n1. Each step has a unique solution $u^{n+1}$, given by a tridiagonal linear system.\n2. The method is unconditionally stable: $\\norm{u^{n+1}}_{2} \\le \\norm{u^n}_2$ for every $r \u003e 0$, where $\\norm{v}_2^2 = \\Delta x \\sum_{j=1}^M v_j^2$.\n3. Assume the exact solution has bounded derivatives $u_{ttt}$, $u_{xxtt}$ and $u_{xxxx}$. Then the local truncation error is $O(\\Delta t^2 + \\Delta x^2)$. On each interval $[0, T]$ the error $\\max_{n \\Delta t \\le T} \\norm{u(\\cdot, t_n) - u^n}_2$ is also $O(\\Delta t^2 + \\Delta x^2)$.\n\n## Remarks\n\nThe vectors $s^{(k)}_j = \\sin(k \\pi x_j)$, $1 \\le k \\le M$, are eigenvectors of $\\delta^2$ with eigenvalues $-\\frac{4}{\\Delta x^2} \\sin^2 \\frac{k \\pi \\Delta x}{2}$, and they are orthogonal.\nIn this basis each step multiplies the $k$-th component by $g_k = \\frac{1 - 2 r \\sigma_k}{1 + 2 r \\sigma_k}$ with $\\sigma_k = \\sin^2 \\frac{k \\pi \\Delta x}{2} \\in (0, 1)$, and $\\abs{g_k} \u003c 1$ for all $r \u003e 0$; this gives clauses 1 and 2.\nClause 3 follows from Taylor expansion about $(x_j, t_n + \\Delta t/2)$ and from stability, as in the [[Lax equivalence theorem|D5M7TRD3MY]].\nThe method is the trapezoidal rule applied to the [[method of lines|FNGWJR2FPK]] semi-discretisation $u' = \\kappa \\delta^2 u$.\nFor large $r$, $g_k$ is close to $-1$ for the high frequencies, so rough initial data produce slowly decaying oscillations: the method is A-stable but not L-stable.\n\n## Explanations\n\n### L1 human\n\nThe Crank–Nicolson method advances the heat equation in time by averaging the explicit and the implicit [[finite difference|X7HYEBA5SA]] formulas.\nThis averaging centres the scheme at the half step, which makes it second-order accurate in time as well as in space.\nIt is stable for every time step, unlike the explicit method, which needs $r \\le 1/2$.\nThe price is a tridiagonal system to solve at each step, which costs only a few operations per grid point.\n\n### L2 human\n\nIt is the default second-order method for diffusion problems, including the Black–Scholes equation in finance.\nFor non-smooth data it is often started with a few backward Euler steps (Rannacher smoothing) to damp the oscillating modes.\nIn several space dimensions the systems are no longer tridiagonal, which motivates alternating-direction implicit methods.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "VP2HN86VAG"
    ],
    "kind": "statement",
    "msc": [
      "65M06",
      "65M12"
    ],
    "name": "Crank–Nicolson method",
    "role": "theorem",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method"
      }
    ],
    "tag": "M92S0Y15N1",
    "uses": [
      "VP2HN86VAG",
      "X7HYEBA5SA",
      "FNGWJR2FPK",
      "D5M7TRD3MY"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/M92S0Y15N1/",
  "links": [
    {
      "field": "about",
      "target": "VP2HN86VAG"
    },
    {
      "field": "uses",
      "target": "VP2HN86VAG"
    },
    {
      "field": "uses",
      "target": "X7HYEBA5SA"
    },
    {
      "field": "uses",
      "target": "FNGWJR2FPK"
    },
    {
      "field": "uses",
      "target": "D5M7TRD3MY"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/M92S0Y15N1.md",
  "msc": [
    "65M06",
    "65M12"
  ],
  "name": "Crank–Nicolson method",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/M92/M92S0Y15N1.md",
  "status": null,
  "tag": "M92S0Y15N1",
  "uri": "m2://M92S0Y15N1",
  "url": "https://tamnd.github.io/math2/wiki/crank-nicolson-method/",
  "writing": {
    "tag": "M92S0Y15N1",
    "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
      }
    ]
  }
}
