Numerical Integration | Free Calculus 2 Lesson (4 College Credits) | UPI Study

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 →

Earn 4 college credits for Calculus 2Recommended for credit by NCCRS · Math 265 · self-paced · one payment, lifetime access

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.

Why take it here

Why students take Calculus 2 with UPI Study

Open the door to higher mathCalculus 2 is the gateway to Calculus 3, differential equations, statistics and most engineering, physics, economics and computer-science degrees. Completing it now lets you qualify for those courses at your university.
Credit at a fraction of the priceThe same 4 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

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.

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?
Numerical integration, also called quadrature, estimates a definite integral by sampling the function at chosen points and combining those values with a weighted formula. You need it when the integrand has no elementary antiderivative, such as e^{-x^2}, or when the function is known only as data, like rainfall rates from a gauge. The three standard methods are the Midpoint, Trapezoidal, and Simpson's Rules, each paired with an error bound.
What is the formula for Simpson's Rule and why does n have to be even?
Simpson's Rule approximates \int_a^b f(x)\,dx by \frac{\Delta x}{3}[f(x_0)+4f(x_1)+2f(x_2)+\cdots+4f(x_{n-1})+f(x_n)], where \Delta x=(b-a)/n. Each parabola passes through three consecutive points and spans two subintervals, so n must be even. Endpoints get weight 1, odd-indexed points get weight 4, and even-indexed interior points get weight 2. The rule is exact for all cubic polynomials.
How do you choose n to make a numerical integration accurate to a given tolerance?
Set the rule's error bound at or below your tolerance, solve for n, and always round up. For example, take \int_1^2 \frac{1}{x}\,dx within 0.0001. Since |f''(x)|=2/x^3\le 2, the Trapezoidal bound K_2(b-a)^3/(12n^2) gives 2/(12n^2)\le 0.0001, so n\ge 40.8 and n=41. Simpson's bound K_4(b-a)^5/(180n^4) with K_4=24 gives n\ge 6.04, which rounds up to the even number 8.
Is the Trapezoidal Rule more accurate than the Midpoint Rule?
No, the Midpoint Rule is typically about twice as accurate, even though trapezoids seem to follow the curve more closely. Its error bound, K_2(b-a)^3/(24n^2), is exactly half the Trapezoidal bound. For a function curving in one direction, the two errors also have opposite signs. For \int_0^2 \frac{dx}{1+x^2} with n=4, Midpoint gives 1.10879 and Trapezoidal gives 1.10385, compared with the exact value \arctan 2\approx 1.10715.

About the Calculus 2 course

How many college credits is Calculus 2?
Calculus 2 (Math 265) carries a NCCRS credit recommendation for 4 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Calculus 2 cost and what is included?
$250, paid once, with lifetime access: all 54 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Calculus 2 take?
It is self-paced with no deadlines. The 54 lessons total about 9 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

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.

Calculus 2
4 credits · NCCRS
Enroll →