{
  "id": "midpoint-rule",
  "title": "Midpoint Rule",
  "lang": "en",
  "source_lang": "en",
  "summary": "The midpoint rule approximates a definite integral by summing rectangle areas whose heights are function values at the midpoints of subintervals.",
  "category": "mathematics",
  "subcategory": "applied",
  "type": "concept",
  "aliases": [
    "Midpoint quadrature",
    "midpoint rectangle rule",
    "composite midpoint rule"
  ],
  "generated_at": "2026-11-06",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/midpoint-rule/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/midpoint-rule/",
      "json": "https://aiwiki.page/zh/midpoint-rule.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The midpoint rule is a method of numerical integration that approximates a definite integral by evaluating the integrand at the midpoint of an interval and multiplying by the interval’s width. Its composite form divides the integration interval into smaller subintervals and adds their midpoint approximations. For sufficiently smooth functions, the composite rule has second-order accuracy: halving the subinterval width reduces the leading error by a factor of four. The name is also used for related methods for solving differential equations, which are distinct from quadrature."
    },
    {
      "heading": "Definition",
      "text": "For a real-valued function \\(f\\) on an interval \\([a,b]\\), with \\(a<b\\), the single-interval midpoint rule is\n\n\\[\\int_a^b f(x)\\,dx \\approx (b-a)f\\!\\left(\\frac{a+b}{2}\\right).\\]\n\nGeometrically, it replaces the area under the graph by the signed area of a rectangle. The rectangle has width \\(b-a\\) and height equal to the function value at the interval’s midpoint. Values below the horizontal axis contribute negative signed area.\n\nFor the composite midpoint rule, partition the interval into \\(n\\) equal parts of width\n\n\\[h=\\frac{b-a}{n}.\\]\n\nTheir midpoints are\n\n\\[m_i=a+\\left(i-\\frac12\\right)h, \\qquad i=1,\\ldots,n.\\]\n\nThe approximation is then\n\n\\[M_n=h\\sum_{i=1}^{n}f(m_i).\\]\n\nThis is a Riemann sum with midpoint sample points. If \\(f\\) is Riemann integrable, \\(M_n\\) converges to its integral as \\(n\\to\\infty\\). This convergence does not, by itself, imply the second-order error rate available for smooth functions.\n\nUnequal subintervals\n\nEqual spacing is not essential. Given a partition\n\n\\[a=x_0<x_1<\\cdots<x_n=b,\\]\n\nwrite\n\n\\[h_i=x_i-x_{i-1}, \\qquad m_i=\\frac{x_{i-1}+x_i}{2}.\\]\n\nThe nonuniform composite rule is\n\n\\[M=\\sum_{i=1}^{n}h_i f(m_i).\\]\n\nUnequal widths allow finer resolution where the integrand changes rapidly and coarser resolution where it is smoother."
    },
    {
      "heading": "Exactness and the role of symmetry",
      "text": "The midpoint rule integrates every polynomial of degree at most one exactly. For\n\n\\[f(x)=\\alpha x+\\beta,\\]\n\nthe average value of \\(f\\) over an interval equals its value at the midpoint. The rule’s degree of precision is therefore one: it is exact for all constant and linear polynomials, but not for all quadratic polynomials.\n\nIts improved accuracy over left- or right-endpoint rectangle rules comes from symmetry. Let\n\n\\[m=\\frac{a+b}{2}, \\qquad h=b-a.\\]\n\nA Taylor expansion about \\(m\\) gives\n\n\\[f(m+t) = f(m)+f'(m)t+\\frac{f''(m)}{2}t^2+\\cdots.\\]\n\nIntegration over the symmetric interval \\([-h/2,h/2]\\) eliminates odd powers of \\(t\\). Consequently, for a sufficiently smooth function,\n\n\\[\\int_a^b f(x)\\,dx = h f(m)+\\frac{h^3}{24}f''(m)+O(h^5).\\]\n\nThe cancellation of the first-derivative term explains why midpoint sampling is more accurate than one-sided endpoint sampling at the same subinterval width. Here \\(O(h^5)\\) uses big-O notation to describe the size of the omitted terms."
    },
    {
      "heading": "Error bounds and convergence order",
      "text": "Define the error as the exact integral minus the approximation:\n\n\\[E_n=\\int_a^b f(x)\\,dx-M_n.\\]\n\nIf the second derivative \\(f''\\) is continuous on \\([a,b]\\), then for some \\(\\xi\\in(a,b)\\),\n\n\\[E_n = \\frac{(b-a)^3}{24n^2}f''(\\xi) = \\frac{(b-a)h^2}{24}f''(\\xi).\\]\n\nThus, if\n\n\\[K=\\max_{x\\in[a,b]}|f''(x)|,\\]\n\nthen\n\n\\[|E_n| \\le \\frac{K(b-a)^3}{24n^2}.\\]\n\nThe error on a single subinterval is \\(O(h^3)\\). Summing over \\(n=(b-a)/h\\) equal subintervals produces a total error of \\(O(h^2)\\), making the composite rule a second-order method.\n\nFor a nonuniform partition, the corresponding bound is\n\n\\[\\left|\\int_a^b f(x)\\,dx-M\\right| \\le \\frac{1}{24} \\sum_{i=1}^{n} h_i^3 \\max_{x\\in[x_{i-1},x_i]}|f''(x)|.\\]\n\nDirection of the error\n\nFor a convex function, the midpoint value is no greater than the average value over the interval. The midpoint rule therefore underestimates the integral. For a concave function, it overestimates it.\n\nIf \\(f''\\) changes sign, errors from different subintervals can cancel. The resulting approximation may be much more accurate than the general error bound suggests.\n\nFor sufficiently smooth \\(f\\), the leading composite error can also be written as\n\n\\[E_n = \\frac{h^2}{24}\\bigl(f'(b)-f'(a)\\bigr)+O(h^4).\\]\n\nIf \\(f'(a)=f'(b)\\), the leading second-order term vanishes, allowing faster convergence."
    },
    {
      "heading": "Example",
      "text": "Consider\n\n\\[I=\\int_0^1 x^2\\,dx=\\frac13.\\]\n\nWith one interval,\n\n\\[M_1=f\\!\\left(\\frac12\\right)=\\frac14.\\]\n\nWith two equal subintervals,\n\n\\[M_2 = \\frac12 \\left[ f\\!\\left(\\frac14\\right) + f\\!\\left(\\frac34\\right) \\right] = \\frac{5}{16}.\\]\n\nThe errors are\n\n\\[I-M_1=\\frac1{12}, \\qquad I-M_2=\\frac1{48}.\\]\n\nDoubling the number of subintervals reduces the error by exactly a factor of four. More generally, since \\(f''(x)=2\\),\n\n\\[I-M_n=\\frac{1}{12n^2}.\\]"
    },
    {
      "heading": "Relationship to other quadrature rules",
      "text": "Endpoint rectangle rules\n\nLeft- and right-endpoint rules use one endpoint rather than the midpoint of each subinterval. For general smooth functions, their composite errors are first order, \\(O(h)\\). The midpoint rule uses the same number of function evaluations but ordinarily achieves second-order accuracy.\n\nTrapezoidal rule\n\nThe trapezoidal rule approximates the integrand by straight lines joining endpoint values. On a uniform grid,\n\n\\[T_n = h\\left[ \\frac{f(a)+f(b)}{2} + \\sum_{i=1}^{n-1}f(a+ih) \\right].\\]\n\nIt is also second order. With the same subinterval width and sufficient smoothness, its leading error is\n\n\\[\\int_a^b f(x)\\,dx-T_n = -\\frac{h^2}{12}\\bigl(f'(b)-f'(a)\\bigr)+O(h^4).\\]\n\nThus its leading error is opposite in sign and twice as large as that of the midpoint rule when the displayed derivative difference is nonzero. This is an asymptotic comparison, not a universal ranking for arbitrary functions or grids.\n\nSimpson’s rule\n\nCombining endpoint and midpoint information gives Simpson’s rule:\n\n\\[\\int_a^b f(x)\\,dx \\approx \\frac{b-a}{6} \\left[ f(a)+4f\\!\\left(\\frac{a+b}{2}\\right)+f(b) \\right].\\]\n\nIf \\(M\\) and \\(T\\) denote the single-interval midpoint and trapezoidal approximations, this expression is\n\n\\[\\frac{2M+T}{3}.\\]\n\nThe combination cancels their leading error terms. Simpson’s rule is exact for polynomials of degree at most three and has fourth-order composite accuracy under suitable smoothness assumptions.\n\nGaussian quadrature\n\nThe midpoint rule is the one-node Gauss–Legendre rule, a special case of Gaussian quadrature. On \\([-1,1]\\), it reads\n\n\\[\\int_{-1}^{1}f(x)\\,dx\\approx 2f(0).\\]\n\nIt is the unique one-node quadrature rule on this interval that integrates every linear polynomial exactly."
    },
    {
      "heading": "Error estimation and implementation",
      "text": "A basic implementation evaluates the function at \\(n\\) midpoints and accumulates the weighted sum. It requires \\(n\\) function evaluations and constant additional storage.\n\nWhen the leading error behaves as \\(Ch^2\\), comparing two resolutions gives the practical estimate\n\n\\[I-M_{2n}\\approx \\frac{M_{2n}-M_n}{3}.\\]\n\nThe extrapolated value\n\n\\[\\frac{4M_{2n}-M_n}{3}\\]\n\ncancels the leading second-order error and is fourth-order accurate when the required smooth error expansion holds.\n\nSuch estimates are not guaranteed bounds without additional assumptions. A narrow peak or unresolved oscillation may be missed by both grids, making their agreement misleading. Also, ordinary midpoint grids with \\(n\\) and \\(2n\\) subintervals are not nested: the old midpoints are not sample points on the refined grid.\n\nIn floating-point arithmetic, rounding errors can eventually limit the benefit of refinement. Summing many values, especially values with substantial cancellation, introduces errors separate from the quadrature error."
    },
    {
      "heading": "Applications and limitations",
      "text": "The midpoint rule is useful when integrand evaluations are inexpensive, moderate accuracy is sufficient, or sampled values naturally represent cell centers. It appears in finite volume methods, where a cell integral may be approximated by the cell’s volume multiplied by a representative midpoint value.\n\nIt does not sample interval endpoints. This can be convenient when an endpoint value is undefined, but it does not remove the effects of a singularity: the usual second-order error bound may fail if derivatives become unbounded near an endpoint.\n\nOther limitations include:\n\n- Limited smoothness. Discontinuities, corners, or unbounded derivatives can reduce the convergence rate.\n- Unresolved structure. Narrow peaks and rapid oscillations may require specialized grids or methods.\n- Fixed sample locations. Existing data cannot generally be used directly unless their locations match the needed midpoints; interpolation introduces additional error.\n- High-dimensional cost. A product midpoint rule using \\(n\\) points in each of \\(d\\) coordinates requires \\(n^d\\) evaluations, illustrating the curse of dimensionality."
    },
    {
      "heading": "Midpoint methods for differential equations",
      "text": "In the numerical solution of an ordinary differential equation\n\n\\[y'=f(t,y),\\]\n\n“midpoint method” commonly refers to either an explicit or an implicit second-order time-stepping method.\n\nThe explicit midpoint method, a Runge–Kutta method, first estimates the state halfway through a step:\n\n\\[k_1=f(t_n,y_n),\\]\n\n\\[k_2=f\\!\\left(t_n+\\frac h2,\\, y_n+\\frac h2 k_1\\right),\\]\n\nthen advances using\n\n\\[y_{n+1}=y_n+h k_2.\\]\n\nThe implicit midpoint method instead satisfies\n\n\\[y_{n+1} = y_n+h\\,f\\!\\left( t_n+\\frac h2,\\, \\frac{y_n+y_{n+1}}2 \\right).\\]\n\nIt generally requires solving an equation for \\(y_{n+1}\\). Although both methods use midpoint evaluations, their stability properties differ substantially. When \\(f\\) depends only on \\(t\\), both reduce to applying midpoint quadrature to the integral over a time step."
    }
  ],
  "links": [
    "numerical-integration",
    "integral",
    "mathematical-function",
    "riemann-sum",
    "riemann-integral",
    "polynomial",
    "taylor-series",
    "big-o-notation",
    "derivative",
    "convex-function",
    "trapezoidal-rule",
    "floating-point-arithmetic",
    "finite-volume-method",
    "interpolation",
    "curse-of-dimensionality",
    "ordinary-differential-equation",
    "runge-kutta-methods",
    "numerical-stability"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}