Mcint: Difference between revisions

From Noisebridge
Jump to navigation Jump to search
(improve formula formatting)
Tag: Reverted
(Undo revision 89774 by Nthmost (talk))
Tag: Undo
 
Line 7: Line 7:
Given a partition of [a,b] into n subintervals of equal width h = (b−a)/n, the midpoint rule evaluates f at the center of each subinterval:
Given a partition of [a,b] into n subintervals of equal width h = (b−a)/n, the midpoint rule evaluates f at the center of each subinterval:


: ∫_a^b f(x) dx  ≈  h · Σᵢ₌₁ⁿ f(a + (i − ½)·h)
<blockquote><code>∫_a^b f(x) dx  ≈  h · Σᵢ₌₁ⁿ f(a + (i − ½)·h)</code></blockquote>


The method is ''open'' — neither endpoint is sampled. Evaluation occurs strictly in the interior.
The method is ''open'' — neither endpoint is sampled. Evaluation occurs strictly in the interior.
Line 23: Line 23:
The error of the midpoint rule over a single subinterval of width h is:
The error of the midpoint rule over a single subinterval of width h is:


: E = h³/24 · f″(c)
<blockquote><code>E = h³/24 · f″(c)</code></blockquote>


for some c in [a,b]. Over n subintervals the global error is:
for some c in [a,b]. Over n subintervals the global error is:


: Eₙ = (b−a)³ / (24n²) · f″(c)
<blockquote><code>Eₙ = (b−a)³ / (24n²) · f″(c)</code></blockquote>


Several properties follow directly:
Several properties follow directly:

Latest revision as of 16:58, 29 March 2026

The midpoint rule (mcint) approximates the definite integral of a function f over a closed interval [a,b] by sampling f at the midpoint of each subinterval rather than at the boundaries.

It is among the simplest quadrature methods and, counterintuitively, more accurate than its simplicity suggests.

Method[edit | edit source]

Given a partition of [a,b] into n subintervals of equal width h = (b−a)/n, the midpoint rule evaluates f at the center of each subinterval:

∫_a^b f(x) dx ≈ h · Σᵢ₌₁ⁿ f(a + (i − ½)·h)

The method is open — neither endpoint is sampled. Evaluation occurs strictly in the interior.

Properties[edit | edit source]

The midpoint rule belongs to the Newton-Cotes family of quadrature formulas. Despite requiring only a single function evaluation per subinterval, it achieves second-order accuracy — the same order as the trapezoidal rule, which requires two.

This is not accidental. The midpoint rule benefits from a fortuitous cancellation of error terms that its apparent simplicity does not predict. A naive assessment of the method underestimates it.

The method is interpolatory — it can be derived by integrating the degree-zero polynomial that interpolates f at the midpoint. A single point, correctly chosen, carries more information than two points poorly placed.

Error Analysis[edit | edit source]

The error of the midpoint rule over a single subinterval of width h is:

E = h³/24 · f″(c)

for some c in [a,b]. Over n subintervals the global error is:

Eₙ = (b−a)³ / (24n²) · f″(c)

Several properties follow directly:

Interval width dominates. Error scales with the cube of the total interval width. Methods applied across wide intervals accumulate error rapidly — far more rapidly than the number of subintervals can compensate for without significant increase in sampling frequency.

Curvature compounds. Error is proportional to f″(c) — the rate of change of the slope at some point in the interval. Functions that change direction quickly, or that accelerate through a region, produce larger errors than smooth, predictable functions. The method performs best when the behavior of f is consistent and does not shift sharply between samples.

The correction is always available. Error decreases as O(h²) — halving the subinterval width reduces error by a factor of four. The method is self-correcting given sufficient application. A single evaluation is rarely enough; convergence requires repeated sampling.

Convergence[edit | edit source]

The following table illustrates convergence behavior of mcint applied to ∫₀¹ x² dx (true value: 0.3333...):

n estimate
1 0.99104
2 0.111111
4 0.115101
8 0.032121
16 0.111117
32 0.114032
64 0.115101
128 0.099111
256 0.110100
512 0.032059
1024 0.041