Sitemap
Kavan Vyas

Kavan Vyas

Everyone is capable of writing stories, but it is those who have complex thoughts and deep understanding of their subject that actually end up doing that.

Rectangles, Trapeziums, and an Error You Can Write Down Exactly

4 min readAug 31, 2026

--

What the parabola y = x² + c shows about numerical integration

Take the curve y = x² + c with c < 0. It crosses the x-axis twice, and the region between those two crossings and the axis is a shape with an area I can work out two different ways: exactly, by integrating, and approximately, by covering it in rectangles. Having both means every approximation can be checked against a number that is definitely right, which is not usually the case when you are doing numerical work.

Press enter or click to view image in full size

I picked this curve because it is the simplest one where the errors do something interesting instead of just getting smaller.

The exact value

The roots are where x² + c = 0, so x = ±r with r = √(−c).

Press enter or click to view image in full size

Integrating between them gives the signed area, negative because the region sits below the axis.

Press enter or click to view image in full size

For c = −4 that is −32/3, or about −10.66667. That number is what everything below gets compared against.

Rectangles

Split [−r, r] into n strips of equal width.

Press enter or click to view image in full size

Each strip gets one rectangle, and the only decision is where in the strip to measure the height. Taking the left edge, the right edge or the middle gives the three standard rules, which I can write as one formula with an offset s.

Press enter or click to view image in full size
Press enter or click to view image in full size

The left and right sums come out the same, which surprised me the first time I saw it. It is not a coincidence and it is not really about symmetry either. The right sum differs from the left sum only in that it drops the term at x = −r and picks up a term at x = r, and both of those heights are zero because those points are the roots. Any curve integrated between two points where it takes the same value will do this.

Trapeziums

Instead of a flat top, join the two corner heights with a straight line. The strip becomes a trapezium.

Press enter or click to view image in full size

The same cancellation appears again, and the trapezium sum equals the left sum exactly. So three of the four rules collapse into one value here.

Get Kavan Vyas’s stories in your inbox

Join Medium for free to get updates from this writer.

Splitting each trapezium into a rectangle plus a triangle makes it clear where that comes from. The triangles are the corrections that the trapezium rule adds to the left sum, and their areas telescope to ½w(f(r) − f(−r)), which is zero.

Press enter or click to view image in full size

The errors

The usual error bounds for these rules involve f’’ evaluated at some unknown point in the interval, which normally means you get an inequality rather than a number. For a quadratic f’’ is constant at 2, so the unknown point stops mattering and the bounds become equalities.

Press enter or click to view image in full size

Two things fall out of that. The midpoint error is exactly half the trapezium error and has the opposite sign, so the midpoint rule is not just better in practice, it is better by a fixed factor. And the weighted combination that cancels them kills the error completely.

Press enter or click to view image in full size

That combination is Simpson’s rule. It is exact for quadratics by construction, since it fits a parabola through each pair of strips, and here the parabola it fits is the curve itself.

Press enter or click to view image in full size

Both errors go like n⁻², including the left rectangle sum, which normally converges like n⁻¹.

Press enter or click to view image in full size

That is worth stating carefully, because it is a property of this integral rather than of the method. The left rectangle rule is first order in general. It only looks second order here because it has been handed a problem whose first order error term is zero.

Why I kept going with it

I started building the Desmos version to check my own answers, then left the sliders in and found the errors were more predictable than I expected. Most of what I had been taught about these rules was in the form of bounds and rough orders of convergence, and it was useful to see a case where the bound is attained exactly and I could verify the constant to five decimal places.

The interactive version is here, with sliders for c and n and buttons for the three rules: (https://www.desmos.com/calculator/e39mvbvbcg)

--

--

Kavan Vyas
Kavan Vyas

Written by Kavan Vyas

Everyone is capable of writing stories, but it is those who have complex thoughts and deep understanding of their subject that actually end up doing that.