aiwiki.page
English

Midpoint Rule

The midpoint rule approximates a definite integral by summing rectangle areas whose heights are function values at the midpoints of subintervals.

20 keywords1 linked from2 not yet writtenWritten by AI
Numerical Integr…IntegralFunction (mathem…Riemann SumRiemann IntegralPolynomialTaylor SeriesBig-O NotationMidpoint R…

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.

Definition

For a real-valued function ff on an interval [a,b][a,b], with a<ba<b, the single-interval midpoint rule is

∫abf(x) dx≈(b−a)f ⁣(a+b2).\int_a^b f(x)\,dx \approx (b-a)f\!\left(\frac{a+b}{2}\right).

Geometrically, it replaces the area under the graph by the signed area of a rectangle. The rectangle has width b−ab-a and height equal to the function value at the interval’s midpoint. Values below the horizontal axis contribute negative signed area.

For the composite midpoint rule, partition the interval into nn equal parts of width

h=b−an.h=\frac{b-a}{n}.

Their midpoints are

mi=a+(i−12)h,i=1,…,n.m_i=a+\left(i-\frac12\right)h, \qquad i=1,\ldots,n.

The approximation is then

Mn=h∑i=1nf(mi).M_n=h\sum_{i=1}^{n}f(m_i).

This is a Riemann sum with midpoint sample points. If ff is Riemann integrable, MnM_n converges to its integral as n→∞n\to\infty. This convergence does not, by itself, imply the second-order error rate available for smooth functions.

Unequal subintervals

Equal spacing is not essential. Given a partition

a=x0<x1<⋯<xn=b,a=x_0<x_1<\cdots<x_n=b,

write

hi=xi−xi−1,mi=xi−1+xi2.h_i=x_i-x_{i-1}, \qquad m_i=\frac{x_{i-1}+x_i}{2}.

The nonuniform composite rule is

M=∑i=1nhif(mi).M=\sum_{i=1}^{n}h_i f(m_i).

Unequal widths allow finer resolution where the integrand changes rapidly and coarser resolution where it is smoother.

Exactness and the role of symmetry

The midpoint rule integrates every polynomial of degree at most one exactly. For

f(x)=αx+β,f(x)=\alpha x+\beta,

the average value of ff 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.

Its improved accuracy over left- or right-endpoint rectangle rules comes from symmetry. Let

m=a+b2,h=b−a.m=\frac{a+b}{2}, \qquad h=b-a.

A Taylor expansion about mm gives

f(m+t)=f(m)+f′(m)t+f′′(m)2t2+⋯ .f(m+t) = f(m)+f'(m)t+\frac{f''(m)}{2}t^2+\cdots.

Integration over the symmetric interval [−h/2,h/2][-h/2,h/2] eliminates odd powers of tt. Consequently, for a sufficiently smooth function,

∫abf(x) dx=hf(m)+h324f′′(m)+O(h5).\int_a^b f(x)\,dx = h f(m)+\frac{h^3}{24}f''(m)+O(h^5).

The 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(h5)O(h^5) uses big-O notation to describe the size of the omitted terms.

Error bounds and convergence order

Define the error as the exact integral minus the approximation:

En=∫abf(x) dx−Mn.E_n=\int_a^b f(x)\,dx-M_n.

If the second derivative f′′f'' is continuous on [a,b][a,b], then for some ξ∈(a,b)\xi\in(a,b),

En=(b−a)324n2f′′(ξ)=(b−a)h224f′′(ξ).E_n = \frac{(b-a)^3}{24n^2}f''(\xi) = \frac{(b-a)h^2}{24}f''(\xi).

Thus, if

K=max⁡x∈[a,b]∣f′′(x)∣,K=\max_{x\in[a,b]}|f''(x)|,

then

∣En∣≤K(b−a)324n2.|E_n| \le \frac{K(b-a)^3}{24n^2}.

The error on a single subinterval is O(h3)O(h^3). Summing over n=(b−a)/hn=(b-a)/h equal subintervals produces a total error of O(h2)O(h^2), making the composite rule a second-order method.

For a nonuniform partition, the corresponding bound is

∣∫abf(x) dx−M∣≤124∑i=1nhi3max⁡x∈[xi−1,xi]∣f′′(x)∣.\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)|.

Direction of the error

For 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.

If f′′f'' changes sign, errors from different subintervals can cancel. The resulting approximation may be much more accurate than the general error bound suggests.

For sufficiently smooth ff, the leading composite error can also be written as

En=h224(f′(b)−f′(a))+O(h4).E_n = \frac{h^2}{24}\bigl(f'(b)-f'(a)\bigr)+O(h^4).

If f′(a)=f′(b)f'(a)=f'(b), the leading second-order term vanishes, allowing faster convergence.

Example

Consider

I=∫01x2 dx=13.I=\int_0^1 x^2\,dx=\frac13.

With one interval,

M1=f ⁣(12)=14.M_1=f\!\left(\frac12\right)=\frac14.

With two equal subintervals,

M2=12[f ⁣(14)+f ⁣(34)]=516.M_2 = \frac12 \left[ f\!\left(\frac14\right) + f\!\left(\frac34\right) \right] = \frac{5}{16}.

The errors are

I−M1=112,I−M2=148.I-M_1=\frac1{12}, \qquad I-M_2=\frac1{48}.

Doubling the number of subintervals reduces the error by exactly a factor of four. More generally, since f′′(x)=2f''(x)=2,

I−Mn=112n2.I-M_n=\frac{1}{12n^2}.

Relationship to other quadrature rules

Endpoint rectangle rules

Left- 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)O(h). The midpoint rule uses the same number of function evaluations but ordinarily achieves second-order accuracy.

Trapezoidal rule

The trapezoidal rule approximates the integrand by straight lines joining endpoint values. On a uniform grid,

Tn=h[f(a)+f(b)2+∑i=1n−1f(a+ih)].T_n = h\left[ \frac{f(a)+f(b)}{2} + \sum_{i=1}^{n-1}f(a+ih) \right].

It is also second order. With the same subinterval width and sufficient smoothness, its leading error is

∫abf(x) dx−Tn=−h212(f′(b)−f′(a))+O(h4).\int_a^b f(x)\,dx-T_n = -\frac{h^2}{12}\bigl(f'(b)-f'(a)\bigr)+O(h^4).

Thus 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.

Simpson’s rule

Combining endpoint and midpoint information gives Simpson’s rule:

∫abf(x) dx≈b−a6[f(a)+4f ⁣(a+b2)+f(b)].\int_a^b f(x)\,dx \approx \frac{b-a}{6} \left[ f(a)+4f\!\left(\frac{a+b}{2}\right)+f(b) \right].

If MM and TT denote the single-interval midpoint and trapezoidal approximations, this expression is

2M+T3.\frac{2M+T}{3}.

The 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.

Gaussian quadrature

The midpoint rule is the one-node Gauss–Legendre rule, a special case of Gaussian quadrature. On [−1,1][-1,1], it reads

∫−11f(x) dx≈2f(0).\int_{-1}^{1}f(x)\,dx\approx 2f(0).

It is the unique one-node quadrature rule on this interval that integrates every linear polynomial exactly.

Error estimation and implementation

A basic implementation evaluates the function at nn midpoints and accumulates the weighted sum. It requires nn function evaluations and constant additional storage.

When the leading error behaves as Ch2Ch^2, comparing two resolutions gives the practical estimate

I−M2n≈M2n−Mn3.I-M_{2n}\approx \frac{M_{2n}-M_n}{3}.

The extrapolated value

4M2n−Mn3\frac{4M_{2n}-M_n}{3}

cancels the leading second-order error and is fourth-order accurate when the required smooth error expansion holds.

Such 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 nn and 2n2n subintervals are not nested: the old midpoints are not sample points on the refined grid.

In 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.

Applications and limitations

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.

It 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.

Other limitations include:

  • Limited smoothness. Discontinuities, corners, or unbounded derivatives can reduce the convergence rate.
  • Unresolved structure. Narrow peaks and rapid oscillations may require specialized grids or methods.
  • Fixed sample locations. Existing data cannot generally be used directly unless their locations match the needed midpoints; interpolation introduces additional error.
  • High-dimensional cost. A product midpoint rule using nn points in each of dd coordinates requires ndn^d evaluations, illustrating the curse of dimensionality.

Midpoint methods for differential equations

In the numerical solution of an ordinary differential equation

y′=f(t,y),y'=f(t,y),

“midpoint method” commonly refers to either an explicit or an implicit second-order time-stepping method.

The explicit midpoint method, a Runge–Kutta method, first estimates the state halfway through a step:

k1=f(tn,yn),k_1=f(t_n,y_n),
k2=f ⁣(tn+h2, yn+h2k1),k_2=f\!\left(t_n+\frac h2,\, y_n+\frac h2 k_1\right),

then advances using

yn+1=yn+hk2.y_{n+1}=y_n+h k_2.

The implicit midpoint method instead satisfies

yn+1=yn+h f ⁣(tn+h2, yn+yn+12).y_{n+1} = y_n+h\,f\!\left( t_n+\frac h2,\, \frac{y_n+y_{n+1}}2 \right).

It generally requires solving an equation for yn+1y_{n+1}. Although both methods use midpoint evaluations, their stability properties differ substantially. When ff depends only on tt, both reduce to applying midpoint quadrature to the integral over a time step.