The midpoint approximation is all about approximating integration. The most fundamental interpretation of the definite integral is as the area under the curve occurs.
So for example definite integral from 2 to 5 of a function f(x) is given as:
$$ \int_2^5 f(x) \; dx $$
This can be represented as the shaded area in a graph where the graph is y = f(x).
So if we want to approximate a definite integral, we will be really thinking of just trying to approximate an area under a graph like the one I have shaded here.
Midpoint Approximation
There are a lot of ways that we can do this but the most fundamental is just using a bunch of different rectangles.
The midpoint rule integration is a specific way of approximating a shaded area like this using bunches of rectangles. What we are going to do is take that interval (in our case 2 to 5), break it up into n even pieces and then draw a rectangle on each subinterval of that width.
Let's see in a graph what we mean.
Visually, midpoint approximation is
So here we use N = 3 rectangles,
We have taken the interval 2 to 5 and broken it up into three even pieces all of width one i.e Δx = 1.
So we have the intervals from 2 to 3, 3 to 4 and 4 to 5. The way we are going to draw a rectangle is to take the midpoint of each of those intervals 2.5, 3.5 and 4.5.
Take the value of the function at each of those points F(2.5), F(3.5) and F(4.5) and make that the height of each of the rectangles.
So in this example on that sub intervals, If you look at that midpoints in the graph and you'll see that's where I've drawn the height of the rectangle.
$$ \int_2^5 f(x) \; dx \; \approx \; f(2.5)(1) \;+\; f(3.5)(1) \;+\; f(4.5)(1) $$
Then we are going to approximate the definite integral just by writing the sum of the rectangles width times height plus width times height plus width times height.
Midpoint approximation of those values are:
$$ \int_2^5 f(x) \; dx \; \approx \; f(2.5)(1) \;+\; f(3.5)(1) \;+\; f(4.5)(1) $$ $$ \int_2^5 f(x) \; dx \; \approx \; 3 \frac{3}{4} \;+\; 3 \frac{3}{4} \;+\; 1 \frac{3}{4} $$ $$ \implies \int_2^5 f(x) \; dx \; \approx \; 5.25 $$
Midpoint Rule Formula
The midpoint rule integration is used for approximating area under the curve of definite integral with the help of Riemann sum, but the difference is that midpoint approximation uses equal width of all sub points and multiplied them with there midpoint values i.e. (mi) in the place of x*i which is used in riemann sum.
Mathematically, midpoint rule formula is stated as :
$$ \int_a^b f(x) \; dx \; \approx \sum_{k=1}^n f(\bar x_k)Δx $$
Basically it's just saying add up the areas of all those rectangles. If you understand that idea, you're in much better shape than if you just try and plug into this formula.
Midpoint Rule Example
Let's do another problem. Estimate the area under the graph of the function f(x)=1/x in an interval from [1,4] by using the midpoint rule having 6 rectangles.
Now in this example we will implement midpoint rule formula for approximating midpoint riemann sum.
$$ \int_1^4 \frac{1}{x} \; dx $$
So graphically it may be represented as:
Here's the region that we're trying to approximate. It's the definite integral from[1,4] of our given function f(x).
Since, we want to use 6 rectangles, so the width of each interval will be:
$$ Δx \;=\; \frac{4-1}{6} \;=\; 0.5 $$
So our intervals are:
$$ 1.0 \;,\; 1.5 \;,\; 2.0 \;,\; 2.5 \;,\; 3.0 \;,\; 3.5 \;,\; 4.0 $$ The midpoints of those intervals are going to be: $$ 1.25 \;,\; 1.75 \;,\; 2.25 \;,\; 2.75 \;,\; 3.25 \;,\; 3.75 $$
Here's what the rectangles actually look like in a graph,
Now we have taken each of those intervals, taken the midpoint of each one and made that the height of the rectangle on that sub interval.
$$ \int_1^4 \frac{1}{x} \; dx \; \approx \; \left[ f(1.25) \;+\; f(1.75) \;+\; f(2.25) \;+\; f(2.75) \;+\; f(3.25) \;+\; f(3.75) \right] \; Δx $$
Now let's actually compute an approximation for this integral.
$$ \int_1^4 \frac{1}{x} \; dx \; \approx \; \left[ \frac{1}{1.25} \;+\; \frac{1}{1.75} \;+\; \frac{1}{2.25} \;+\; \frac{1}{2.75} \;+\; \frac{1}{3.25} \;+\; \frac{1}{3.75} \right] (0.5) $$ $$ \int_1^4 \frac{1}{x} \; dx \; \approx \; 1.377 $$
So that's the area under the curve which we want to approximate. If we want a better approximation we can just use more rectangles, instead of using 6 rectangles we can use 10 and 20 or a thousand.
Now let's calculate the exact answer by evaluating the definite integral for checking the results obtained from the midpoint rule
If we actually carry out the definite integral:
$$ \int_1^4 \frac{1}{x} \; dx \;=\; ln(x) \Biggl|_1^4 $$ $$ \int_1^4 \frac{1}{x} \; dx \;=\; ln \; 4 \;-\; ln \; 1 $$
Since ln(1) = 0, So
$$ \int_1^4 \frac{1}{x} \; dx \;=\; ln \; 4 \;=\; 1.386 $$
So the exact answer is 1.386 and this represents the area under the curve as we see in this example.
The midpoint riemann sum approximates the exact answer of the area under the curve 1.377 by using midpoin rule itegration which is very close to 1.386.
So the midpoint rule is a better method if you wish to approximate the definite integral or find the area under the curve.