{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $n \\ge 1$, let $x$ be a fixed point, and let $\\phi_0(x), \\ldots, \\phi_n(x)$ be numbers that satisfy the three-term [[recurrence|0FYX44GP92]]\n$$\\phi_{k+1}(x) = \\alpha_k(x)\\, \\phi_k(x) + \\beta_k(x)\\, \\phi_{k-1}(x), \\qquad 1 \\le k \\le n-1,$$\nfor given coefficients $\\alpha_k(x)$ and $\\beta_k(x)$.\nLet $a_0, \\ldots, a_n$ be numbers and $S(x) = \\sum_{k=0}^{n} a_k \\phi_k(x)$.\nSet $b_{n+1} = b_{n+2} = 0$ and, for $k = n, n-1, \\ldots, 1$,\n$$b_k = a_k + \\alpha_k(x)\\, b_{k+1} + \\beta_{k+1}(x)\\, b_{k+2},$$\nwhere $\\alpha_n(x)$, $\\beta_n(x)$ and $\\beta_{n+1}(x)$ may be given any values in these formulas, since they multiply $b_{n+1} = 0$ or $b_{n+2} = 0$.\nThen\n$$S(x) = a_0\\, \\phi_0(x) + b_1\\, \\phi_1(x) + \\beta_1(x)\\, b_2\\, \\phi_0(x).$$\n\n## Remarks\n\nWrite $a_k = b_k - \\alpha_k b_{k+1} - \\beta_{k+1} b_{k+2}$ for $1 \\le k \\le n$ and substitute in $\\sum_{k \\ge 1} a_k \\phi_k$.\nAfter collecting terms, the coefficient of $b_j$ for $j \\ge 3$ is $\\phi_j - \\alpha_{j-1}\\phi_{j-1} - \\beta_{j-1}\\phi_{j-2} = 0$, and the coefficient of $b_2$ is $\\phi_2 - \\alpha_1 \\phi_1 = \\beta_1 \\phi_0$; only the terms in the formula remain.\nFor the [[Chebyshev polynomials|M6EAR1JHPP]] $T_k$ one has $\\phi_0 = 1$, $\\phi_1 = x$, $\\alpha_k = 2x$ and $\\beta_k = -1$, so $\\sum_{k=0}^n a_k T_k(x) = a_0 + x b_1 - b_2$.\nCheck with $n = 2$: $b_2 = a_2$, $b_1 = a_1 + 2x a_2$, and $a_0 + x(a_1 + 2x a_2) - a_2 = a_0 + a_1 x + a_2(2x^2 - 1)$, which is $a_0 T_0 + a_1 T_1 + a_2 T_2$.\nFor the monomials $\\phi_k = x^k$, with $\\alpha_k = x$ and $\\beta_k = 0$, the algorithm is [[Horner's method|FYBQ3Z52Z7]].\nThe cost is $O(n)$ operations, and the values $\\phi_k(x)$ for $k \\ge 2$ are never formed.\n\n## Explanations\n\n### L1 human\n\nMany useful functions are sums of special polynomials, such as Chebyshev or Legendre polynomials, each defined by a recurrence from the two before.\nComputing every polynomial value and then adding is possible, but Clenshaw found a shorter route.\nIt runs a similar recurrence backwards, starting from the last coefficient, and reads off the sum at the end.\nIt plays for these families the role that Horner's rule plays for ordinary polynomials.\n\n### L2 human\n\nThe algorithm is the standard way to evaluate a truncated Chebyshev series, for instance in function libraries and in Chebyshev spectral methods.\nIt works for any family defined by a three-term recurrence, so for all classical orthogonal polynomials and also for some special functions such as Bessel functions.\nThe backward recurrence is the transpose of the forward one, which explains why only $b_1$ and $b_2$ appear in the result.\nIts rounding error behaviour is good for Chebyshev series on $[-1, 1]$, though near the endpoints $\\pm 1$ the errors can be amplified.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "0FYX44GP92"
    ],
    "kind": "statement",
    "msc": [
      "65D20",
      "33C45"
    ],
    "name": "Clenshaw algorithm",
    "role": "proposition",
    "same_as": {
      "wikidata": "Q1067155",
      "wikipedia": "Clenshaw algorithm"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Clenshaw_algorithm"
      }
    ],
    "tag": "476ZQPMZHP",
    "uses": [
      "0FYX44GP92",
      "M6EAR1JHPP",
      "FYBQ3Z52Z7"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/476ZQPMZHP/",
  "links": [
    {
      "field": "about",
      "target": "0FYX44GP92"
    },
    {
      "field": "uses",
      "target": "0FYX44GP92"
    },
    {
      "field": "uses",
      "target": "M6EAR1JHPP"
    },
    {
      "field": "uses",
      "target": "FYBQ3Z52Z7"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/476ZQPMZHP.md",
  "msc": [
    "65D20",
    "33C45"
  ],
  "name": "Clenshaw algorithm",
  "prov": null,
  "role": "proposition",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/476/476ZQPMZHP.md",
  "status": null,
  "tag": "476ZQPMZHP",
  "uri": "m2://476ZQPMZHP",
  "url": "https://tamnd.github.io/math2/wiki/clenshaw-algorithm/",
  "writing": {
    "tag": "476ZQPMZHP",
    "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
      }
    ]
  }
}
