UPI Study › Courses › Calculus 2 › Free lessons › Lesson 1.7 Free lesson
Numerical Integration
Calculus 2 · Chapter 1: Review & Advanced Integration TechniquesSection 1.7 · lesson 7 of 5411 min · free
← A General Strategy for IntegrationNext lesson: L'Hopital's Rule →
In this lesson
When no formula exists, sample instead.
- Apply the Midpoint, Trapezoidal and Simpson's Rules
- Read each rule's weighting pattern off its geometry
- Use error bounds to guarantee an accuracy
- Choose n to hit a target tolerance
Transcript
Everything said in the video, section by section (1,666 words). Read along, or search it.
MAT-265 - Calculus 2 · Section 1.7
Numerical Integration
Engineers at a national weather service are tracking how much rain falls during a storm. A rain gauge reports the rate of rainfall every few minutes. What they get is a string of numbers. Not a tidy equation. Total rainfall is the integral of that rate. But there's nothing to integrate. Only data points. And that situation is far more common than the textbook version suggests. A function may be known only at discrete points. Or it may have a perfectly good formula whose antiderivative can't be written down at all. The famous example is the bell curve from statistics. The integral of e to the minus x squared. That function is perfectly smooth and perfectly continuous. And it has no elementary antiderivative. There is no combination of polynomials, exponentials, logarithms or trig functions whose derivative equals it. The Fundamental Theorem still guarantees the definite integral exists as a number. It just can't be reached by finding an antiderivative. So we do something different. We sample.
The Problem
When No Formula Exists
Numerical integration — also called quadrature — sidesteps the antiderivative entirely. Instead of an exact symbolic answer, it produces an accurate numerical estimate. You sample f at well-chosen points, and combine those samples with a weighted formula. This section develops the three most widely used rules. Midpoint, Trapezoidal, and Simpson's. Plus the error bounds that tell you how many samples you actually need for a target accuracy. And that last part matters more than students expect. An estimate without an error bound isn't an answer. It's a guess. In every rule, the setup is the same. Divide the interval from a to b into n equal subintervals. Each has width delta x, equal to b minus a, over n. And the division points are x naught equals a, up to x n equals b.
Rule 1
The Midpoint Rule
Start with the simplest accurate approach. Approximate the region under f with rectangles. But here's the refinement. Rather than using the left or right endpoint for each rectangle's height, use the height at the center of each subinterval. That's the Midpoint Rule. And centering matters more than you'd think. Where the curve rises, the rectangle cuts off a triangle of area on the left — but it adds back a similar triangle on the right. The errors largely offset. Which makes it noticeably more accurate than left- or right-endpoint rectangles, for free. The estimate is just the sum of rectangle areas. Each with width delta x, and height f evaluated at the midpoint. Let's test it. Estimate the integral from zero to two of one over one plus x squared, with n equals four. Delta x is zero point five. So the midpoints are zero point two five, zero point seven five, one point two five, and one point seven five. Evaluate f at each. Sum the heights. Multiply by delta x. You get one point one zero eight seven nine. The exact value is arctangent of two, about one point one zero seven one five. So the estimate is off by roughly one and a half thousandths. From four rectangles. That's genuinely impressive.
Rule 2
The Trapezoidal Rule
Now replace each flat-topped rectangle with a trapezoid. The slanted top connects the function values at the two endpoints of the subinterval. And the reasoning is intuitive. A straight chord follows a gently curving function better than a horizontal line does. Trapezoids hug the curve more closely. The area of a single trapezoid is the average of the two end heights, times the width. Add up all n trapezoids and collect terms — and something nice happens. Every interior point is shared by two trapezoids, so it gets counted twice. Which gives you the weighting pattern. Endpoints carry weight one. All interior points carry weight two. Run the same integral with four trapezoids. Now you sample the endpoints instead of the midpoints. You get one point one zero three eight five. That's off by about three and a third thousandths. Now hold on. Compare that to the Midpoint estimate, which was off by only one and a half thousandths. The Midpoint Rule was actually closer. And that's not a fluke. For a function curving in one direction, the Midpoint and Trapezoidal errors have opposite signs — and the Midpoint error is typically about half the size.
Figure 1.7.1
The Same Curve, Approximated Three Ways
Let's look at all three side by side, because the geometry tells you everything. On the left, the Midpoint Rule. Rectangles touching the curve at each subinterval's center. You can see the overshoot on one side of each rectangle being paid back on the other. In the middle, the Trapezoidal Rule. Straight chords connecting endpoint values. The chords cut corners on a curve that bends — which is exactly where its error comes from. And on the right, Simpson's Rule. Parabolic arcs. Each arc spans two subintervals and actually bends to follow the curve. Look at how little gap is left. That's the whole argument for Simpson's Rule in one picture.
Rule 3
Simpson's Rule - Fit Parabolas, Not Lines
So let's build it. Midpoint and Trapezoidal both approximate the curve with straight pieces. Simpson's Rule does better by fitting parabolas — curved arcs that can match the bending of a smooth function far more faithfully. Each parabola is drawn through three consecutive points on the curve. Which means it spans two subintervals at once. And that's exactly why Simpson's Rule requires n to be even. The subintervals have to pair up cleanly. Two per parabola. Carry out the algebra of fitting a parabola through three equally spaced points and integrating it, and you get a weighting pattern of one, four, two, four, two, and so on, ending in one. The pattern is easy to remember if you know where it comes from. Endpoints get weight one. Odd-indexed points — the parabola midpoints — get weight four. Even-indexed interior points, where one parabola hands off to the next, get weight two. Run the same integral with n equals four, using the same endpoint values as the trapezoidal example. You get one point one zero five one three. Off by about two thousandths here. And on smoother integrands, the advantage over the other two grows dramatically. One more thing worth knowing. Because a parabola can curve, Simpson's Rule is exact not just for straight lines, but for any cubic polynomial. That's a surprising bonus, and it explains a lot of its remarkable accuracy.
Error Bounds
How Wrong Could You Be?
An estimate is only useful if its accuracy can be guaranteed. So each rule comes with an error bound. A formula giving the largest possible difference between your estimate and the true value. And the bounds depend on how curvy f is. For Midpoint and Trapezoidal, that's measured by the second derivative. For Simpson's, by the fourth derivative. Let K two be a number with the absolute second derivative at most K two across the interval. And let K four do the same job for the fourth derivative. Two features of these bounds really stand out. First. The Trapezoidal bound is exactly twice the Midpoint bound. That confirms what the worked examples already showed you. Midpoint is the more accurate of the two straight-line methods. Second, and more important. The Midpoint and Trapezoidal errors shrink like one over n squared. Simpson's error shrinks like one over n to the fourth. So doubling n cuts the first two errors to a quarter. But it cuts Simpson's error to a sixteenth. That is why Simpson's Rule reaches high accuracy with far fewer function evaluations.
Choosing n
Working Backwards From a Tolerance
Let's use those bounds the way you'll actually use them. Working backwards from a required accuracy. Suppose you need the integral from one to two of one over x, accurate to within one ten-thousandth. Using the Trapezoidal Rule. Here f of x is one over x, so the second derivative is two over x cubed. On the interval from one to two, that's largest at x equals one. So K two is two. Set the bound below the tolerance and solve. You get n squared at least sixteen sixty-six point seven, so n at least forty point eight. Round up — always up — and you need forty-one subintervals. Now do the same problem with Simpson's Rule. The fourth derivative of one over x is twenty-four over x to the fifth. So K four is twenty-four at x equals one. The condition gives n to the fourth at least thirteen thirty-three point three, so n at least six point zero four. Since n must be even, round up to eight. Eight subintervals, where the Trapezoidal Rule needed forty-one. That is a vivid demonstration of the one-over-n-to-the-fourth advantage. One last thing to think about. Simpson's Rule actually blends the other two. Algebraically, S sub two n equals one third T sub n, plus two thirds M sub n. Why might a weighted average that leans twice as heavily on the Midpoint estimate be smarter than a plain average? Think about the errors having opposite signs, with Midpoint's roughly half as large.
Key Takeaways
What to Carry Forward
Five things to carry forward. Numerical integration estimates a definite integral from sampled values. It's essential when f has no elementary antiderivative, or when f is known only as data. The Midpoint Rule uses rectangles centered on each subinterval. The Trapezoidal Rule uses straight chords, with weights one, two, two, and so on, ending in one. Simpson's Rule fits parabolas over pairs of subintervals, so n must be even, and the weights follow one, four, two, four, ending in one. Error bounds use the max of the second derivative for Midpoint and Trapezoidal, and the max of the fourth derivative for Simpson's. And the Trapezoidal bound is exactly twice the Midpoint bound. Midpoint and Trapezoidal errors shrink like one over n squared. Simpson's shrinks like one over n to the fourth — so it hits a target accuracy with far fewer subintervals. Set the relevant bound at or below your tolerance, and round n up. To the next even number, for Simpson's. That closes Chapter One. Next up is Chapter Two — Indeterminate Forms and Improper Integrals, beginning with L'Hopital's Rule.
About Calculus 2 at UPI Study
Calculus 2 (Math 265) is a self-paced online course of 54 video lessons in 10 chapters, from integration techniques to series, parametric curves and vectors. It carries a NCCRS credit recommendation for 4 semester credits.
Every lesson video and transcript is free on pages like this one. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take Calculus 2 with UPI Study
Where the credit goes
Universities that work with NCCRS
Calculus 2 carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Numerical Integration
What is numerical integration and when do you need it?
What is the formula for Simpson's Rule and why does n have to be even?
How do you choose n to make a numerical integration accurate to a given tolerance?
Is the Trapezoidal Rule more accurate than the Midpoint Rule?
About the Calculus 2 course
How many college credits is Calculus 2?
How much does Calculus 2 cost and what is included?
Which universities accept UPI Study credits?
How long does Calculus 2 take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 4 credits in Calculus 2.
54 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
4 credits · NCCRSEnroll →