Integral Approximations

integral area


Integration is the best way to find the area from a curve to the axis: we get a formula for an exact answer.

integral area small delta x

But Integration can sometimes be hard or impossible to do!

Don't worry though, because we can add up lots of slices
to get an approximate answer.

Let's have a go!


Let's use f(x) = ln(x) from x = 1 to x = 4

We actually can integrate that and get the true answer of 2.54517744447956....

But imagine we can't, and the only thing we can do is calculate values of ln(x):

Let's use a slice width of 1 to make it easy to see what is going on (but smaller slices are better).

And there are a few different methods we can use:


Left Rectangular Approximation Method (LRAM)

integral approximation Left Rectangular Graph

This method uses rectangles whose height is the left-most value. Areas are:

Adding these up gets 1.791759, much lower than 2.545177. Why?

Because we are missing all that area between the tops of the rectangles and the curve.

This is made worse by a curve that is constantly increasing. When a curve goes up and down more, the error is usually less.


Right Rectangular Approximation Method (RRAM)

integral approximation Right Rectangular Graph

Now we calculate the rectangle's height using the right-most value. Areas are:

Adding these up gets 3.178054, which is now much higher than 2.545177, because we have included areas between the tops of the rectangles and the curve.


Midpoint Rectangular Approximation Method (MRAM)

integral approximation Midpoint Rectangular Graph

We can also use the midpoint! Areas are:

Adding these up gets 2.574519..., which is quite close to 2.545177.


Trapezoidal Rule

integral approximation: Trapezoidal Rule

We can use both sides for a triangular effect at the top, which usually make trapezoids.

integral approximation: Trapezoidal Rule zoomed in

The calculation just averages the left and right values. Areas are:

Adding these up gets 2.484907, which is still a bit lower than 2.545177, mostly because the curve is concave down over the interval.

Notice that in practice each value gets used twice (except first and last) and then the whole sum is divided by 2:

ln(1) + ln(2) 2 × 1 + ln(2) + ln(3) 2 × 1 + ln(3) + ln(4) 2 × 1

1 2 × ( ln(1) + ln(2) + ln(2) + ln(3) + ln(3) + ln(4) )

1 2 × ( ln(1) + 2 ln(2) + 2 ln(3) + ln(4) )

So we can have a general formula:

Δx 2 × ( f(x0) + 2f(x1) + 2f(x2) + ... 2f(xn-1) + f(xn) )

By the way, this method is just the average of the Left and Right Methods:

Trapezoidal Approximation = LRAM + RRAM 2


Note: the previous 4 methods are also called Riemann Sums after the mathematician Bernhard Riemann.


Simpson's Rule

integral approximation: Simpsons Rule

An improvement on the Trapezoidal Rule is Simpson's Rule. It is based on using parabolas at the top instead of straight lines. The parabolas often get quite close to the real curve:

integral approximation: Simpsons Rule zoomed in

It sounds hard, but we end up with a formula like the trapezoid formula (but we divide by 3 and use a 4,2,4,2,4 pattern of factors):

Δx 3 × ( f(x0) + 4f(x1) + 2f(x2) + ... 4f(xn-1) + f(xn) )

But: n must be even. So let's take 6 slices of 0.5 each:

0.5 3 × ( f(1) + 4f(1.5) + 2f(2) + 4f(2.5) + 2f(3) + 4f(3.5) + f(4) )

Plugging in values of ln(1) etc gives:

0.5 3 × ( 15.2679... )


This is a great result when compared to 2.545177....

Plus and Minus

definite integral cos(x) from 1 to 3

When the curve is below the axis the value of the integral  is negative!

So we get a "net" value.

If we want a total area (say we wanted to paint it) we can use the absolute value function abs(). Or manually find where the curve crosses the axis and then work out separate integrals and reverse the negatives before adding.

Error and Accuracy

Let's compare them all:

f(x)=ln(x) N = 3     N = 6     N = 100  

Estimation Error   Estimation Error   Estimation Error
LRAM 1.791759 0.753418   2.183140 0.362037   2.524327 0.020850
RRAM 3.178054 -0.632877   2.876287 -0.331110   2.565916 -0.020739
MRAM 2.574519 -0.029342   2.552851 -0.007674   2.545206 -0.000029
Trapezoidal Rule 2.484907 0.060271   2.529713 0.015464   2.545121 0.000055
Simpson’s Rule (N must be even)   2.544648 0.000529   2.545177 <0.000001

Simpson’s Rule rules! And it is just as easy to use as the others.

Of course a different function will produce different results. Why not try one yourself?

Maximum Error

In practice we won't know the actual answer ... so how do we know how good our estimate is?

You can get a good feel by trying different slice widths.

And there are also these formulas for the maximum error of approximation (these are for the worst case and the actual error will hopefully be a lot smaller):

For Midpoint: |E| = K(b-a)3 24n2

For Trapezoidal: |E| = K(b-a)3 12n2

For Simpson's: |E| = M(b-a)5 180n4


(By "greatest" we mean the maximum absolute value.)

a, b and n are easy, but how do we find K and M ?

Example: f(x) = ln(x) between 1 and 4

Let's find some derivatives first, we will need them:

The greatest K could be at the start, end, or somewhere in between:

So K = 1 (the maximum absolute value)

Same for M, but higher derivatives:

So M = 6 (the maximum absolute value)

For just 6 slices, the Maximum Errors are:

Midpoint: |E| = 1(4-1)3 24×62 = 0.03125

Trapezoidal: |E| = 1(4-1)3 12×62 = 0.0625

Simpson's: |E| = 6(4-1)5 180×64 = 0.00625

Shapes we Know

The curve may have a shape we know, and we can use geometry formulas like these examples:

Example: Triangle

integral approximation triangle
f(x) = 2 − x, from 0 to 2

A = ½ × 2 × 2 = 2

Example: Rectangle

integral approximation rectangle
f(x) = 2, from 0 to 3

A = 2 × 3 = 6

Example: Semicircle

integral approximation circle
f(x) = √(1 − x2), from −1 to +1

A = π r2 / 2 = π / 2



We can estimate the area under a curve by slicing a function up

There are many ways of finding the area of each slice such as:
We can use error formulas to find the largest possible error in our estimate
Basic geometry formulas can sometimes help us find areas under the curve