In this video we will give an example of how you use Simpson's rule to integrate. We will
do this using a spreadsheet. The idea is we have a number of discrete data point so we
cannot integrate analytically. We have to integrate numerically however to demonstrate
how this works we will use a function that we could integrate analytically and then we
will generate data points from that function and compare this to the spreadsheet. The function
is a simple polynomial function and what we want to do is integrate from 0 to 2.8. I am
showing the integration here and applying the limits where we substitute 2.8 and then
all the terms are 0 at the other limit. Here is the function and the integral corresponds
to the area under the curve which is 5.8856. For Simpson's rule we are going to assume
that we only have these data points indicated here and we do not know what the function
is so we want to integrate it numerically. I will start here. And we will create an interval
which we will call h. We will integrate over every 2h. For example it is easy to show here.
From 0.4 to 0.8 we will get this area. Let's look at this area to begin with. If we do
the Simpson's rule to get that area we will take h/3 times the function evaluated at the
lower limit. In this case the function a 0.4 plus the 4 times the function evaluated at
0.6 plus the function evaluated at the upper limit 0.8. That is going to be a pretty good
approximation. The way we can look at this is h times to multiplied by the same function
and then divided by 6. We evaluate this function six times and divide it by six to get an average
that weights towards the middle value. Then we will multiply by 2h. For this integration
from 0.4 to 0.8 we are saying our beginning area is x from 0.4 to 0.8. The function is
some average value that we get from taking 4 times this function here plus this function
plus this function and then dividing by 6. We will just step along. We will do this on
a spreadsheet. We have data just every 2 tenths in x values. We are assuming that we do not
actually know the formula for the function and we just have a set of data points. The
h interval is 0.2. To apply Simpson's rule we will say from 0 to 0.4 we have h/3 times
D5 plus 4 times D6 plus D7. This is the integral from here to here. All we have done is copy
this and paste it in every other one because the integral is 2h that we integrate over.
This cell is just the sum of these values to get the total integral. You notice that
we get 5.8856 which is actually the same value we get from our analytical solution. The Simpson's
rule for a well behaved function works quite well. We can certainly do this with fewer
data points. The idea is the same as the number of data points decreases the accuracy should
go down. When we have made experimental measurements and we have measurements of some values for
let's say time and concentration we do not have any functional form then we can use Simpson's
rule to get the area under the curve or the integral. f(x)*dx