Integral Calculus 201-SN3-RE (201-NYB) • CEGEP, Montreal

Revision sheet: numerical integration, 201-SN3-RE (201-NYB)

This sheet does not copy out the three formulas of the chapter: they are in your notes. It deals with what the marking scheme penalizes in 201-SN3-RE (formerly 201-NYB), namely the error bound, the coefficients that get swapped and the number of subintervals, three places where an otherwise correct approximation loses half its marks.

It is written for CEGEP students in the Science program (Sciences de la nature). Once the sheet is read, the corrected exercise set on the same chapter puts every reflex to the test.

Mark this sheet as read or add it to your favourites: a free account, no password, keeps your read sheets and favourites from one visit to the next, tells you which chapter to tackle next and lets you ask for the method or exercise you are missing. Create your space, an email is enough.

The thread of the chapter

A numerical method does not give a number, it gives a number AND an ERROR BOUND. Without the bound, nothing tells you how many decimal places can be trusted, and the answer is then worth no more than the first number that comes to mind.

This chapter is part of 201-SN3-RE (201-NYB), Integral Calculus

The essentials

The three formulas, with the same step

  • • Step: h=b−anh=\frac{b-a}{n}, where nn is the number of SUBINTERVALS, not the number of points.
  • • MIDPOINT: Mn=h[f(xˉ1)+⋯+f(xˉn)]M_{n}=h\left[f(\bar{x}_{1})+\cdots+f(\bar{x}_{n})\right], where xˉi\bar{x}_{i} is the midpoint of the ii-th subinterval.
  • • TRAPEZOIDS: Tn=h2[f(x0)+2f(x1)+⋯+2f(xn−1)+f(xn)]T_{n}=\frac{h}{2}\left[f(x_{0})+2f(x_{1})+\cdots+2f(x_{n-1})+f(x_{n})\right]. Coefficients 1,2,2,…,2,11, 2, 2,\ldots,2, 1.
  • • SIMPSON: Sn=h3[f(x0)+4f(x1)+2f(x2)+4f(x3)+⋯+4f(xn−1)+f(xn)]S_{n}=\frac{h}{3}\left[f(x_{0})+4f(x_{1})+2f(x_{2})+4f(x_{3})+\cdots+4f(x_{n-1})+f(x_{n})\right], with nn EVEN.
  • • There are always n+1n+1 points x0,…,xnx_{0},\ldots,x_{n} for nn subintervals.
0.511.522.533.50.20.40.60.811.2y = 1/xT₄
Four trapezoids on [1,3]\left[1, 3\right]: each roof is a CHORD of the curve, and since 1x\frac{1}{x} is convex, every roof lies above it, so T4T_{4} overestimates the integral.

Simpson's coefficients start and end with 11, and alternate 4,2,4,2,…,44, 2, 4, 2,\ldots,4 in between: the 44 always sits on the ODD indices.

The error bounds, and where to look for the maximum

  • • Trapezoids: ∣ET∣≤K2(b−a)312n2\left|E_{T}\right|\le\frac{K_{2}\left(b-a\right)^{3}}{12n^{2}}, where K2K_{2} bounds ∣f′′∣\left|f''\right| on [a,b]\left[a,b\right].
  • • Midpoint: ∣EM∣≤K2(b−a)324n2\left|E_{M}\right|\le\frac{K_{2}\left(b-a\right)^{3}}{24n^{2}}, twice as good as the trapezoids.
  • • Simpson: ∣ES∣≤K4(b−a)5180n4\left|E_{S}\right|\le\frac{K_{4}\left(b-a\right)^{5}}{180n^{4}}, where K4K_{4} bounds ∣f(4)∣\left|f^{(4)}\right|.
  • • K2K_{2} and K4K_{4} are looked for over the WHOLE interval, by studying whether the derivative concerned is increasing or decreasing.
  • • Doubling nn divides the trapezoidal error by 44 and Simpson's error by 1616.

The bound is an UPPER BOUND: the actual error is almost always much smaller, and that does not prove the bound is wrong.

The direction of the error, given by concavity

  • • ff CONVEX, that is f′′>0f''>0: the trapezoids OVERESTIMATE, the midpoint rule UNDERESTIMATES.
  • • ff CONCAVE, f′′<0f''<0: the trapezoids underestimate, the midpoint rule overestimates.
  • • The two methods therefore BRACKET the integral, which gives a free check.
  • • Simpson is exact on every polynomial of degree at most THREE, which explains its high order.
0.511.522.533.50.20.40.60.811.2chordtangenty = 1/x
On the slice [1,3]\left[1, 3\right], the chord lies ABOVE the convex curve; the tangent line at the midpoint, which has the area of the midpoint rectangle, lies BELOW it: the two methods bracket the integral.

The mistakes that cost marks

These are the errors I correct most often in session. Each one costs marks on a paper, even when the reasoning behind it is right.

1. Handing in an approximation without an error bound

half the question

What not to write

“T4=1.1167T_{4}=1.1167.”

What to write

“T4=1.1167T_{4}=1.1167, with ∣ET∣≤2(2)312(16)=0.0833\left|E_{T}\right|\le\frac{2(2)^{3}}{12(16)}=0.0833: the exact value is therefore between 1.0331.033 and 1.2001.200.”

Why: An approximation without a bracket says nothing: it could be wrong from the first decimal place. The bound is what turns a number into a result, and the marking scheme always gives it marks of its own, separate from the computation.

2. Confusing the number of subintervals with the number of points

the whole question, since every evaluation point is shifted

What not to write

“I have five points, so n=5n=5 and h=3−15=0.4h=\frac{3-1}{5}=0.4.”

What to write

“Five points make FOUR subintervals: n=4n=4 and h=3−14=0.5h=\frac{3-1}{4}=0.5.”

x₀x₁x₂x₃x₄hhhh5 points, 4 subintervals
Five points x0,…,x4x_{0},\ldots,x_{4} mark off FOUR subintervals: n=4n=4 and h=3−14=0.5h=\frac{3-1}{4}=0.5.

Why: The points run from x0x_{0} to xnx_{n}, so there are n+1n+1 of them. The immediate check: the last point computed must land exactly on bb. If it lands anywhere else, the step is wrong.

3. Using Simpson with an odd number of subintervals

the whole question

What not to write

“n=5n=5, I apply Simpson.”

What to write

“Simpson requires an EVEN nn: I take n=6n=6.”

12345123456alone
Each parabola covers TWO subintervals. With n=5n=5, the fifth one is left alone (in red): Simpson does not apply.

Why: The method replaces the curve with a parabola on EACH PAIR of subintervals: an even number of them is needed for the partition to close up. With an odd nn, the last pair is incomplete and the coefficients do not end on a 11.

4. Swapping Simpson's coefficients

the whole question

What not to write

h3[f(x0)+2f(x1)+4f(x2)+2f(x3)+f(x4)]\frac{h}{3}\left[f(x_{0})+2f(x_{1})+4f(x_{2})+2f(x_{3})+f(x_{4})\right]

What to write

h3[f(x0)+4f(x1)+2f(x2)+4f(x3)+f(x4)]\frac{h}{3}\left[f(x_{0})+4f(x_{1})+2f(x_{2})+4f(x_{3})+f(x_{4})\right]

Why: The 44 goes on the ODD indices, the middle point of each parabola. The foolproof check: the sum of the coefficients must equal 3n3n, here 1212; with 1+4+2+4+1=121+4+2+4+1=12 ✓ and 1+2+4+2+1=101+2+4+2+1=10 ✗.

5. Looking for the maximum of the second derivative in the wrong place

the whole bound, which becomes nearly thirty times too small

What not to write

“f′′(x)=2x3f''(x)=\frac{2}{x^{3}}, I take K2=f′′(3)=227K_{2}=f''(3)=\frac{2}{27}.”

What to write

“∣f′′∣\left|f''\right| is DECREASING on [1,3]\left[1, 3\right], so its maximum is at x=1x=1: K2=2K_{2}=2.”

0.511.522.533.50.511.52K₂ = 2, at x = 1f″(3) = 2/27|f″| = 2/x³
∣f′′(x)∣=2x3\left|f''(x)\right|=\frac{2}{x^{3}} decreases on [1,3]\left[1, 3\right]: its maximum is at x=1x=1, K2=2K_{2}=2. The value at 33 is the MINIMUM.

Why: K2K_{2} bounds ∣f′′∣\left|f''\right| over the whole interval, so it is a MAXIMUM, not a value picked at random. Study whether f′′f'' is increasing or decreasing in one line, or compare its values at the two endpoints when it is monotonic. An underestimated bound is worse than no bound at all: it claims a false accuracy.

6. Forgetting the h2\frac{h}{2} or the h3\frac{h}{3}

the whole question, since the answer is four times too large

What not to write

T4=1+2(0.667)+2(0.5)+2(0.4)+0.333=4.467T_{4}=1+2(0.667)+2(0.5)+2(0.4)+0.333=4.467

What to write

T4=0.52×4.467=1.1167T_{4}=\frac{0.5}{2}\times 4.467=1.1167

Why: The factor in front of the brackets carries the whole dimension: without it, you are adding heights, not areas. The check is immediate: the integral of 1x\frac{1}{x} on [1,3]\left[1, 3\right] is clearly of the order of 11, since the function lies between 13\frac{1}{3} and 11 there, over a width of 22.

7. Thinking that a wide bound signals a mistake

time wasted redoing a correct computation

What not to write

“The bound is 0.0830.083 but the actual error is 0.0180.018: my bound is wrong.”

What to write

“A bound is an UPPER BOUND on the error: 0.018≤0.0830.018\le 0.083 is exactly what is expected.”

Why: The bound assumes the worst case, where ∣f′′∣\left|f''\right| would reach its maximum everywhere. In practice it is usually three to five times too generous. What would be alarming is the reverse: an actual error LARGER than the announced bound.

8. Looking for nn without solving the inequality

1 to 2 marks, and an answer that cannot be checked

What not to write

“For an accuracy of 10−410^{-4}, I take n=100n=100 at random.”

What to write

“I solve 2(8)12n2≤10−4\frac{2(8)}{12n^{2}}\le 10^{-4}, that is n2≥13 333n^{2}\ge 13\,333, so n≥116n\ge 116: I take n=116n=116.”

Why: The question “how many subintervals” expects a solved inequality, not a guess. Isolate nn, take the square root, ROUND UP, and for Simpson move up again to the next even integer.

Which method to choose

Which method, depending on what the problem asks

The three methods serve the same purpose with different accuracies. The problem almost always imposes which one, but you need to know why.

  • If the problem gives a table of values at the endpoints of the subintervals → TRAPEZOIDS or SIMPSON, the only ones that use just these points

    Example: flow rate readings every two hours

  • If the problem gives the values at the MIDPOINTS → the MIDPOINT rule, twice as accurate as the trapezoids for the same work

    Example: measurements taken at the centre of each slice

  • If the problem requires high accuracy with few evaluations → SIMPSON, whose error decreases like 1n4\frac{1}{n^{4}} instead of 1n2\frac{1}{n^{2}}

    Example: four correct decimal places with n=8n=8

  • If the antiderivative does not exist in elementary form → any of the three, but with its error bound

    Example: ∫01e−x2dx\int_{0}^{1}e^{-x^{2}}dx

  • If the integrand is a polynomial of degree at most three → SIMPSON is EXACT: the error is zero, whatever nn

    Example: ∫02x3dx\int_{0}^{2}x^{3}dx gives exactly 44 from n=2n=2 on

The midpoint rule and the trapezoids bracket the integral when the concavity does not change: computing both gives a bracket without any theoretical bound.

How the answer is expected to be written

A marker ticks steps. Here they are in order, with the concluding sentence expected word for word.

An approximation with its bound, written up for the marker

When to use it: Every numerical integration question, even when the bound is not explicitly asked for.

  1. 1 Compute h=b−anh=\frac{b-a}{n} and LIST the n+1n+1 points x0,…,xnx_{0},\ldots,x_{n}.
  2. 2 Draw up a table of the f(xi)f(x_{i}), with enough decimal places for the accuracy required.
  3. 3 Apply the formula writing out the coefficients, then multiply by the factor in front of the brackets.
  4. 4 Compute the required derivative, study whether it increases or decreases, and give KK as a justified MAXIMUM.
  5. 5 Apply the bound formula and conclude with a BRACKET.

Concluding sentence

T4=1.1167T_{4}=1.1167 with ∣ET∣≤0.0833\left|E_{T}\right|\le 0.0833, so ∫13dxx\int_{1}^{3}\frac{dx}{x} lies between 1.0331.033 and 1.2001.200.

The trap: Giving KK without justifying that it is a maximum. The sentence “∣f′′∣=2x3\left|f''\right|=\frac{2}{x^{3}} is decreasing on [1,3]\left[1, 3\right], so its maximum is f′′(1)=2f''(1)=2” is worth a mark on its own.

Marking: Usually 1 mark for the step and the points, 2 marks for the approximation, 1 mark for a justified KK, 1 mark for the bound and the bracket.

Check before you hand in

Five minutes of checking recover more marks than one more problem started in a hurry.

The typical problem, taken apart

Trapezoids and Simpson on the same integral, with the bounds

Approximate ∫13dxx\displaystyle\int_{1}^{3}\frac{dx}{x} with n=4n=4, by the trapezoidal rule and then by Simpson's rule, and give an error bound in each case.

0.511.522.533.50.20.40.60.811.2chordparabola
The parabola through (1,1)(1, 1), (2,0.5)(2, 0.5) and (3,13)(3, \frac{1}{3}) hugs the curve far better than the chord: this substitution is what gives Simpson its order four.

Step 1

h=3−14=0.5h=\frac{3-1}{4}=0.5, and the FIVE points are 11, 1.51.5, 22, 2.52.5, 33. Values: 11, 0.66670.6667, 0.50.5, 0.40.4, 0.33330.3333.

Why

Five points for four subintervals, and the last one lands exactly on 33: both checks of the step are done before any computation.

Step 2

Trapezoids: T4=0.52[1+2(0.6667)+2(0.5)+2(0.4)+0.3333]=0.25×4.4667=1.1167T_{4}=\frac{0.5}{2}\left[1+2(0.6667)+2(0.5)+2(0.4)+0.3333\right]=0.25\times 4.4667=1.1167.

Why

The coefficients 1,2,2,2,11, 2, 2, 2, 1 add up to 8=2n8=2n ✓, and the factor h2\frac{h}{2} is applied at the end. Both checks take five seconds.

Step 3

Trapezoidal bound: f′′(x)=2x3f''(x)=\frac{2}{x^{3}}, decreasing on [1,3]\left[1, 3\right], so K2=f′′(1)=2K_{2}=f''(1)=2. Hence ∣ET∣≤2(3−1)312(4)2=16192=0.0833\left|E_{T}\right|\le\frac{2(3-1)^{3}}{12(4)^{2}}=\frac{16}{192}=0.0833.

Why

The fact that ∣f′′∣\left|f''\right| is decreasing is written out explicitly: it is what justifies that 22 really is a MAXIMUM, and it is the point most papers lose.

Step 4

Simpson: S4=0.53[1+4(0.6667)+2(0.5)+4(0.4)+0.3333]=0.16667×6.6=1.1000S_{4}=\frac{0.5}{3}\left[1+4(0.6667)+2(0.5)+4(0.4)+0.3333\right]=0.16667\times 6.6=1.1000.

Why

Coefficients 1,4,2,4,11, 4, 2, 4, 1, sum 12=3n12=3n ✓, with the 44 on the odd indices. The factor is h3\frac{h}{3} and not h2\frac{h}{2}: the two are easily confused.

Step 5

Simpson bound: f(4)(x)=24x5f^{(4)}(x)=\frac{24}{x^{5}}, decreasing, so K4=24K_{4}=24. Hence ∣ES∣≤24(2)5180(4)4=76846 080=0.0167\left|E_{S}\right|\le\frac{24(2)^{5}}{180(4)^{4}}=\frac{768}{46\,080}=0.0167.

Why

Same method, one derivative higher. Simpson's bound is five times tighter than the trapezoidal one for the same number of evaluations, which is the whole point of the method.

Step 6

Check: the exact value is ln⁡3=1.0986\ln 3=1.0986. Trapezoidal error 0.0181≤0.08330.0181\le 0.0833 ✓; Simpson error 0.0014≤0.01670.0014\le 0.0167 ✓. Simpson is thirteen times more accurate.

Why

Both actual errors are well below their bounds, as expected of an upper bound. The ratio between the two confirms Simpson's higher order, which is the conclusion the question is after.

The conclusion, written out

T4=1.1167T_{4}=1.1167 to within 0.08330.0833 and S4=1.1000S_{4}=1.1000 to within 0.01670.0167, while ln⁡3=1.0986\ln 3=1.0986: both brackets contain the exact value, and Simpson's is much tighter.

The classic mistake on this problem: Taking K2=f′′(3)=227K_{2}=f''(3)=\frac{2}{27} because it is the last value computed. The bound would become 0.00310.0031, smaller than the actual error of 0.01810.0181: it would claim an accuracy the computation does not have.

Learn by heart

  • • h=b−anh=\frac{b-a}{n}, with nn SUBINTERVALS and n+1n+1 points.
  • • Trapezoids: coefficients 1,2,…,2,11, 2,\ldots,2, 1 and factor h2\frac{h}{2}. Sum of the coefficients 2n2n.
  • • Simpson: coefficients 1,4,2,…,4,11, 4, 2,\ldots,4, 1 and factor h3\frac{h}{3}, with nn EVEN. Sum 3n3n.
  • • ∣ET∣≤K2(b−a)312n2\left|E_{T}\right|\le\frac{K_{2}(b-a)^{3}}{12n^{2}}, ∣EM∣≤K2(b−a)324n2\left|E_{M}\right|\le\frac{K_{2}(b-a)^{3}}{24n^{2}}, ∣ES∣≤K4(b−a)5180n4\left|E_{S}\right|\le\frac{K_{4}(b-a)^{5}}{180n^{4}}.
  • • KK is a MAXIMUM over the whole interval, justified by whether the derivative increases or decreases.
  • • Convex: trapezoids above, midpoint below. The two bracket the integral.
  • • Simpson is EXACT on every polynomial of degree at most three.
  • • To find nn: solve the inequality and ROUND UP.

Frequently asked questions

Why do you have to give an error bound?

Because an approximation without a bound does not say how many decimal places can be trusted. The bound turns a number into a bracket around the exact value, which is the only usable result. The marking scheme always gives it marks of its own, separate from those for computing the approximation.

Why does Simpson's rule need an even number of subintervals?

Because the method replaces the curve with a parabola on each pair of consecutive subintervals. An even number of them is therefore needed for the partition to close up exactly. With an odd number, the last pair is incomplete and the coefficients do not close the pattern.

How do you find the constant K in the error bound?

It is an upper bound for the absolute value of the derivative concerned over the whole interval, so its maximum. Study whether this derivative increases or decreases, which is often obvious, and take its largest value. Choosing a value at random gives a wrong bound, sometimes smaller than the actual error.

Does the trapezoidal rule always overestimate the integral?

Only when the function is convex, that is when its second derivative is positive. The chords then lie above the curve. On a concave function it is the other way round, and the midpoint rule always errs in the opposite direction, which gives a free bracket.

How many subintervals do you need for a given accuracy?

Write the inequality stating that the error bound is less than the accuracy required, then isolate the number of subintervals. Always round up, and for Simpson move up again to the next even integer, since the method requires one.

Practise it

Corrected exercises: Numerical integration, 201-SN3-RE (201-NYB)

A method is proved on a paper, not on a sheet. The set for the same chapter takes each of these traps into a problem, with the solution written out step by step.

  • 15 corrected exercises
  • 150 points
  • 225 minutes
Do the exercises
Something missing from this sheet? A method, a trap, an exercise to practise it, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

Previous sheet Area between curves Next sheet Applications of integration

© Ahmed Squalli Houssaini. Revision sheet published at www.letuteurscientifique.ca/en/fiches/cegep-calc2-numerical-integration. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

See also

Looking for a 201-SN3-RE (201-NYB) tutor in Montreal?

Get in touch for a first session. We go back over the moves that cost marks on the integral calculus exam, then we test them on exercises at the real level of CEGEP tests.

Site by Studio Squalli