{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $a \u003c b$, let $f \\colon [a, b] \\to \\R$ be twice continuously differentiable, let $N \\ge 1$, $h = (b - a)/N$, and let $T_N(f)$ be the composite [[trapezoidal rule|FH0538XCZR]] with $N$ subintervals.\nThen there is $\\xi \\in [a, b]$ with\n$$\\int_a^b f(x)\\, dx - T_N(f) = -\\frac{(b - a)\\, h^2}{12}\\, f''(\\xi).$$\nIn particular,\n$$\\left| \\int_a^b f(x)\\, dx - T_N(f) \\right| \\le \\frac{(b - a)\\, h^2}{12} \\max_{a \\le x \\le b} \\abs{f''(x)}.$$\n\n## Remarks\n\nOn one subinterval $[x_{i-1}, x_i]$, the [[interpolation error formula|HASA2XSG66]] gives $f(x) - L(x) = \\tfrac{1}{2} f''(\\eta_x)(x - x_{i-1})(x - x_i)$ for the linear interpolant $L$.\nSince $(x - x_{i-1})(x - x_i) \\le 0$ there, the [[mean value theorem for integrals|0N91N98EG5]] gives the local error $-\\tfrac{h^3}{12} f''(\\xi_i)$.\nSumming over the $N$ subintervals and using the intermediate value theorem for $f''$ gives the global formula with $N h^3 = (b - a) h^2$.\nExample: $f(x) = x^2$ on $[0, 1]$ with $N = 2$: the error is $\\tfrac{1}{3} - \\tfrac{3}{8} = -\\tfrac{1}{24}$, and the formula gives $-\\tfrac{1 \\cdot 1/4}{12} \\cdot 2 = -\\tfrac{1}{24}$.\nWithout the smoothness hypothesis the rate $h^2$ can fail: for $f(x) = \\sqrt{x}$ on $[0, 1]$, whose second derivative is unbounded near $0$, the error is only of order $h^{3/2}$.\nMathlib proves the bound in the form `trapezoidal_error_le_of_c2`.\n\n## Explanations\n\n### L1 human\n\nThe trapezoidal rule replaces the curve by straight chords, and the mistake on each piece depends on how much the curve bends there.\nThe theorem says the total mistake is at most a constant times the largest bending times the square of the piece width.\nSo using twice as many pieces makes the error about four times smaller.\nThe sign also tells something: for a convex function, with $f'' \\ge 0$, the trapezoidal rule overestimates the integral.\n\n### L2 human\n\nThis bound is the model for error analysis of composite [[Newton–Cotes formulas|BQPQAY1FDJ]]: a local error of order $h^{d+2} f^{(d+1)}$ summed over $N$ pieces gives a global error of order $h^{d+1}$.\nIt also tells how many subintervals are needed for a given tolerance, once a bound on $\\abs{f''}$ is known.\nThe Euler–Maclaurin formula refines it into an expansion of the error in even powers of $h$, which is the basis of Richardson extrapolation and [[Romberg's method|VP40T7MHGM]].\nFor smooth periodic functions all the correction terms vanish, which explains the very fast convergence of the trapezoidal rule in that case.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "FH0538XCZR"
    ],
    "kind": "statement",
    "msc": [
      "65D32",
      "41A55",
      "65D30"
    ],
    "name": "Error bound for the trapezoidal rule",
    "role": "theorem",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Trapezoidal_rule"
      }
    ],
    "tag": "Q0M7PT9VN2",
    "uses": [
      "FH0538XCZR",
      "0Y9D2FJRQ4",
      "HASA2XSG66",
      "0N91N98EG5"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/Q0M7PT9VN2/",
  "links": [
    {
      "field": "about",
      "target": "FH0538XCZR"
    },
    {
      "field": "uses",
      "target": "FH0538XCZR"
    },
    {
      "field": "uses",
      "target": "0Y9D2FJRQ4"
    },
    {
      "field": "uses",
      "target": "HASA2XSG66"
    },
    {
      "field": "uses",
      "target": "0N91N98EG5"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/Q0M7PT9VN2.md",
  "msc": [
    "65D32",
    "41A55",
    "65D30"
  ],
  "name": "Error bound for the trapezoidal rule",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/Q0M/Q0M7PT9VN2.md",
  "status": null,
  "tag": "Q0M7PT9VN2",
  "uri": "m2://Q0M7PT9VN2",
  "url": "https://tamnd.github.io/math2/wiki/error-bound-for-the-trapezoidal-rule/",
  "writing": {
    "tag": "Q0M7PT9VN2",
    "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
      }
    ]
  }
}
