# How Do You Calculate the Midpoint Riemann Sum?

A Riemann sum is a method of approximating the area under the curve of a function. It adds together a series of values taken at different points of that function and multiplies them by the intervals between points. The midpoint Riemann sum uses the x-value in the middle of each of the intervals.

### Determine the interval and the total width

Riemann sums are designated by a capital sigma in front of a function. The sigma signals that you add together all of the values found at regular intervals (i) over the given span of the sum. The total width or span is the horizontal length from one endpoint to the other, often starting from 0. For example, the function might be f(x) = (x^2) / 2 + 1, and you could be asked to calculate the area under the curve from x = 0 to x = 4 using an interval of 1.

### Write and test a formula for the rectangles

The formula must produce a series of rectangles. Each rectangle's area is calculated by adding the base or interval width by the value of the function at one point for each interval. To use the midpoint method, you use the x-value in the middle of each interval. For the example function, you would have to take values at x =1/2, 3/2, 5/2, 7/2. These can be simplified to x = n*i - i/2, where i = 1, and where n is the number of the interval. Test your formula.

### Add together the areas of the rectangles

Because of the distributive property, you can write the sum as: Area = i*( f(n*i - i/2) + ...f or each value of 'n') In the case of f(x) = (x^2)/2 + 1, the area estimate and midpoint Riemann sum is 1*(f(1/2) + f(3/2) +f (5/2) + f(7/2))