Investigating integration from first principles using Excel
The definite integral equals the area between the function and the x-axis (where any area above the x-axis is positive and the area below is negative). This is because is defined to be the limit of a sum of the areas of rectangles between the function and the x-axis as the number of rectangles approaches infinity. There are a few different ways to choose the height of each rectangle, for example should the left or right corner touch the graph of the function?
1)Above is the graph of with five rectangles between 0 and 5. Draw the same except let the left corner of the rectangle touch the graph of the function. Which of these is an over- or under-estimate to the exact area under the curve?
Given that generally we get an over-estimate from one choice and an underestimate from the other, it should make sense to take the average of these two areas (to get a better approximation). Taking the average of the areas of the two rectangles is the same as using the area of the trapezium as shown below. Recall that the area of a trapezium is the base length times the average of the heights.
With a finite number of rectangles or trapezia you will usually only get an approximation for the area under a curve, to get better accuracy you need to increase the number of rectangles or trapezia (this means the width of each rectangle/trapezia has to decrease too).
2)In the figures below which is a better approximation for the area under the curve, 4 rectangles or 8?
The more rectangles/trapezia we use the closer we get to the true area under the curve. We would like to choose the biggest number we know and used that; we would like to use infinity if we could! We can examine what happens to the area as the number of rectangles/trapezia approaches infinity (i.e. gets larger and larger), this should settle to a limit.
Open the Excel file ‘Trapezoidal rule’.
This spreadsheet is currently set up to use the trapezoidal rule to approximate the area under between a start point (a) and an end point(b)with 10 trapezia. First change the start and end point values and the number of trapezia to see what changes.
A cubic function
3)The design of this spreadsheet means that you should not ask for more than 10 000 trapezia. What happens when more than 10000 is used?
4)Use the spreadsheet to get a good approximation to the area betweenand the x-axis when x is between 0 and 1.
5)If you know how to integrate, calculate and compare this to your answer above.
6)Integration is defined in such a way that swapping the limits of integration will change the sign of the integral, i.e. .Can this be seen using the spreadsheet?
7)Integration is defined in such a way that if the limits of integration are the same the integral will be zero, i.e. . Can this be seen using the spreadsheet?
A polynomial function
Let’s change the function we are numerically integrating to .Before you have made any changes, the formula in the D6 cell should be =IF(A6>0,B6^3,0). Here B6 is our input or x value, and the ^3 gives us as required.
Step 1:Since B6 is our x, in the cell D6 we replace B6^3 with -2*B6^4+4*B6 ^3-B6+3 and hit enter.
Step 2: Click back onto D6, and to fill down, double click on the bottom right corner of the D6 cell.
Step 3: The abovesteps must be repeated for E6, except this function’s input or x value is C6.
8)Approximate for n trapezia and fill in the following table
Approx
9)From the above what do you think the integral should evaluate to? Check your answer if you know how to integrate.
10)Play around with the start and end points. There are two x intercepts for this polynomial. You will not be able to find them exactly but try to find an approximation for themby noticing when the area starts to decrease. To get a better approximation use more trapezia.
Other functions
Change the formulas for the left and right heights to return EXP(x), where x is B6 or C6, as discussed in the above three steps.
11)Fill out the following to approximate and compare this to the exact answer.
Approx
Change the formulas for the left and right heights to return COS(x), where x is B6 or C6, as discussed in the above three steps.
12)Find an approximation for does this agree with your thoughts?Recall is written in Excel as =PI().
13)Find a good approximation for
Teacher Resource Investigatingintegration from first principles using Excel
- The rectangles that touch on the left corner will be an underestimate of the area under the curve and the rectangles that touch on the right will be an over-estimate.
- Eight rectangles is a closer fit to the curve, there is less white space between the rectangles and the curve when we use larger numbers and hence eight rectangles give a better approximation that four.
- Each trapezium that is added after 10 000 reduces the area given away from its true value and approaches 0. Notice with one million trapezia the area given is quite close to zero.
- Approximately 0.250000003
- The integral evaluates to be 0.25 which is quite close to the above.
- Yes
- Yes
- The first x-intercept is around -0.87669 and the second is around 2.05451 (students should NOT try to get this level of accuracy though)
n / 1 / 10 / 100 / 1 000 / 10 000
Approx / 2 / 5.14688 / 5.199466688 / 5.199994667 / 5.199999947
- It appears to converge to 5.2 and integration confirms this.
n / 1 / 10 / 100 / 1 000 / 10 000
Approx / 1.859140914 / 1.719713491 / 1.718296147 / 1.718281972 / 1.71828183
Since I think Excel gave us a good approximation.
- Excel will tell you the area is zero for small numbers of trapezia and return numbers very close to zero for larger numbers of trapezia. From a graph of cosine it is clear the area above the x-axis and the area below the x-axis are the same, and hence the integral evaluates to zero.
- It appears the area is converging to 2 square units. Which I think is quite nice!