This is the corrected exercise set on numerical integration for Integral Calculus, 201-SN3-RE (formerly 201-NYB), the chapter that takes over when the Fundamental Theorem of Calculus can do nothing more. Part A sets up the three methods: rectangle sums (left, right and midpoint) and their direct link with Riemann sums, the trapezoidal rule, which replaces the steps of the staircase with line segments, and Simpson's rule, which passes a parabola through three consecutive points, with the parity condition that the exam tests every term; then the exact relations between the three methods (exercise 4) and arc length, their most common use (exercise 5). Part B moves up to exam level: error bounds and the order of convergence, the number of subintervals needed to guarantee a required accuracy, the two situations where numerical integration is not a fallback but the only option, then the machine-precision floor (exercise 9) and the singularities that empty the error bound (exercise 10). Part C goes through five classics (exercises 11 to 15): bracketing an integral between the left and right rectangle sums, the length of a sine arch where the trapezoids beat Simpson, the closed rules and the midpoint rule on a concave function, the cross-section and flow rate of a river, and the period of a pendulum at large amplitudes.
This set is written for CEGEP students in the Science program (Sciences de la nature) taking Integral Calculus, 201-SN3-RE (201-NYB). Depending on the CEGEP, this chapter is covered at the end of the term or folded into the chapter on the definite integral: check your teacher's course outline.
The chapter corrects an illusion that the rest of the term keeps alive: the idea that every integral can be computed in the end, provided you know enough techniques. That is false, and provably false. The function e−x2, which governs all of statistics, has no elementary antiderivative, and no algebraic skill will change that. Numerical integration is therefore the only chapter of the course that deals with the general case, and it is the one an engineer will use most often.
Self-checking setType your answers and check them question by question: the page tells you right or wrong before you open the solution. With an account, every answer right on the first try earns points, and your right answers stay filled in when you come back.
•Split [a,b] into n subintervals of width h=nb−a, with the points xi=a+ih for i=0,…,n.
•RECTANGLES: left Ln=h[f(x0)+⋯+f(xn−1)]; right Rn=h[f(x1)+⋯+f(xn)]; MIDPOINT Mn=h[f(m1)+⋯+f(mn)] where mi is the centre of the i-th subinterval.
•TRAPEZOIDS: Tn=2h[f(x0)+2f(x1)+2f(x2)+⋯+2f(xn−1)+f(xn)]. The coefficients are 1,2,2,…,2,1. Also Tn=2Ln+Rn.
•SIMPSON: Sn=3h[f(x0)+4f(x1)+2f(x2)+4f(x3)+⋯+4f(xn−1)+f(xn)]. Coefficients 1,4,2,4,…,4,1. n must be EVEN.
•Trapezoidal error bound: ∣ET∣≤12n2K(b−a)3, where K≥∣f′′(x)∣ on [a,b].
•Simpson error bound: ∣ES∣≤180n4M(b−a)5, where M≥f(4)(x) on [a,b].
•ORDER OF CONVERGENCE: doubling n divides the trapezoidal error by 4 (order 2) and the Simpson error by 16 (order 4). Simpson's rule is exact for every polynomial of degree at most 3.
•Direction of the trapezoidal error: if f is CONVEX, or concave up (f′′>0), the trapezoids OVERESTIMATE; if f is concave down, they underestimate. The midpoint rule errs in the opposite direction.
Part A: The methods and how they are related (/50)
Exercise 1: Why approximate, and rectangle sums
The figure shows y=x1 on [1,2], whose area is exactly ln2. We will use it as a test bench: since the exact value is known, the error of each method can be measured.
a) Give two reasons why a definite integral may have to be computed numerically rather than exactly. Illustrate each one with an example.
b) For ∫12xdx with n=4, compute h and the five points xi, then the LEFT rectangle sum L4.
c) Compute the MIDPOINT rectangle sum M4. Compare L4 and M4 with the exact value ln2≈0.6931472: which one is better, and why could this be predicted?
d) What exact link is there between these sums and the definition of the integral seen in the chapter on the definite integral?
Show the solution
Answers
a)No elementary antiderivative (e−x2), or only data
b)h=0.25; L4≈0.7595
c)M4≈0.6912, about 34 times better
d)Riemann sums stopped at a finite n
a)
First reason: the function has NO elementary antiderivative. This is the case for e−x2 (the normal distribution in statistics), xsinx (optics) and 1+x3: no finite combination of the usual functions integrates them, and this is a theorem, not an admission of ignorance. Second reason: there is NO formula for f at all, only measured values. A speed reading every two seconds, a river flow recorded every hour, a pressure curve coming out of a sensor: the Fundamental Theorem requires an antiderivative, hence a formula, and there is none. In both cases numerical integration is not an approximation of convenience, it is the only route available.
b)
h=nb−a=42−1=0.25. Points: x0=1, x1=1.25, x2=1.5, x3=1.75, x4=2. Values of f(x)=x1: 1; 0.8; 0.6666667; 0.5714286; 0.5. Left rectangles (leave out the LAST value): L4=0.25[1+0.8+0.6666667+0.5714286]=0.25×3.0380952=0.7595238. The gap with ln2 is 0.0663766: a large overestimate, as expected, since x1 is decreasing and each rectangle is built on its higher edge.
c)
Midpoints of the four subintervals: 1.125; 1.375; 1.625; 1.875. Values: 0.8888889; 0.7272727; 0.6153846; 0.5333333. So M4=0.25×2.7648795=0.6912199. Error: ∣0.6912199−0.6931472∣=0.0019273, against 0.0663766 for L4: the MIDPOINT rule is about 34 times better. This could be predicted: on each subinterval, the midpoint rectangle crosses the curve and partly makes up on one side for what it cuts off on the other, whereas the left rectangle always errs in the same direction. An error that alternates cancels out; an error that accumulates never does.
d)
These sums ARE Riemann sums, except that we do not take the limit. By definition, ∫abf(x)dx=limn→∞∑i=1nf(xi∗)Δx for any choice of sample points xi∗ in the subintervals: taking the left endpoint gives Ln, the right endpoint Rn, the centre Mn. The chapter on the definite integral used these sums to DEFINE the integral and prove the Fundamental Theorem, by pushing them to infinity; numerical integration goes the other way and uses them to COMPUTE, stopping at a finite n. The whole question then becomes: what error do we make by stopping, and that is the subject of Part B.
Tick the exercises you have done or want to review: a free account, no password, keeps your ticks and your right answers from one visit to the next, tells you which chapter to tackle next and lets you ask for the exercise you are missing. Create your space, an email is enough.
Exercise 2: The trapezoidal rule
Replace each step of the staircase with a segment joining its two ends: the idea is elementary and the gain is considerable.
a) Derive the trapezoidal rule by computing the area of one elementary trapezoid, then summing. Where do the coefficients 1,2,2,…,2,1 come from?
b) Compute T4 for ∫12xdx and give the error.
c) Check the relation Tn=2Ln+Rn on this example.
d) Does T4 overestimate or underestimate? Relate the answer to the concavity of x1 and state the general rule.
Show the solution
Answers
a)Interior points counted twice: 1,2,…,2,1
b)T4≈0.6970, error ≈0.0039
c)R4≈0.6345 and 2L4+R4=T4
d)Overestimates: x1 is convex
a)
On the subinterval [xi−1,xi], replace the curve with the segment joining (xi−1,f(xi−1)) to (xi,f(xi)). The resulting figure is a trapezoid with “bases” f(xi−1) and f(xi) and height h, so its area is 2h[f(xi−1)+f(xi)]. Summing over the n subintervals: Tn=2h∑i=1n[f(xi−1)+f(xi)]. The coefficients 1,2,…,2,1 then explain themselves: each INTERIOR point x1,…,xn−1 belongs to TWO consecutive trapezoids (it is the right end of one and the left end of the next), so it is counted twice; the two END points x0 and xn belong to a single trapezoid and are counted once. Each roof joins the curve at both ends of its subinterval, so the rule is exact for every linear function, where a left or right rectangle is exact only for constants: this is why the error falls like n21 instead of n1 (exercise 6).
b)
With the values already computed: T4=20.25[1+2(0.8)+2(0.6666667)+2(0.5714286)+0.5]=0.125[1+1.6+1.3333333+1.1428571+0.5]=0.125×5.5761905=0.6970238. Error: ∣0.6970238−0.6931472∣=0.0038766. Compare with the 0.0663766 of the left rectangles: here the trapezoidal rule is 17 times more accurate, for exactly the same number of function evaluations. It is the best return on effort in the chapter.
c)
R4 is obtained by leaving out the FIRST value: R4=0.25[0.8+0.6666667+0.5714286+0.5]=0.25×2.5380952=0.6345238. Average: 2L4+R4=20.7595238+0.6345238=21.3940476=0.6970238=T4 ✓. The relation can be read straight off the formula: adding Ln and Rn counts each interior point twice and the endpoints once, which is exactly the pattern 1,2,…,2,1; all that is left is to divide by 2. In practice, this means the trapezoidal rule costs NOTHING more than the rectangles: it simply averages the two errors, which have opposite signs.
d)
T4=0.6970238>ln2: the rule OVERESTIMATES. Explanation by concavity: f(x)=x1 has second derivative f′′(x)=x32>0 on [1,2], so the function is CONVEX (concave up). Now the chord joining two points of a convex curve lies ABOVE the curve: each trapezoid therefore holds a little more than the true area, and the sum overestimates. General rule: f convex gives an overestimate with the trapezoids, f concave an underestimate. The MIDPOINT rule errs in the opposite direction (it underestimated here, M4<ln2 ✓), which is no coincidence and suggests that a weighted average of the two should be excellent: that is exactly what Simpson's rule is, since one can show that S2n=32Mn+Tn.
Exercise 3: Simpson's rule
The trapezoids replace the curve with straight lines. Simpson replaces it with PARABOLAS, and the gain in accuracy is spectacular for the same cost.
a) What principle is Simpson's rule based on? How many points are needed to determine a parabola, and what condition does this impose on n?
b) Compute S4 for ∫12xdx and give the error. Compare with T4.
c) A student applies Simpson's rule with n=5 subintervals. What happens, and what should the student do?
d) Show that Simpson's rule gives the EXACT value of ∫02x3dx with only n=2. What does this result reveal?
Show the solution
Answers
a)Parabolas on pairs: n even
b)S4≈0.693254, error ≈1.07×10−4
c)Does not apply: take n=4 or 6
d)S2=4 exactly: Simpson is exact up to degree 3
a)
Principle: instead of approximating f with line segments, approximate it with ARCS OF PARABOLAS. A parabola y=ax2+bx+c has three coefficients, so THREE points are needed to determine it: the subintervals are grouped IN PAIRS and a parabola is passed through (x0,f(x0)), (x1,f(x1)), (x2,f(x2)), then through the next three, and so on. The condition follows at once: since the subintervals must be paired, their number n must be EVEN. This also explains the alternating coefficients 1,4,2,4,…,4,1: the points with an ODD index are the middle points of each parabola (coefficient 4), the interior points with an EVEN index are shared by two neighbouring parabolas (coefficient 2), and the two endpoints belong to only one parabola (coefficient 1). Three points per arc instead of two, plus the free extra degree of part d): the error then falls like n41 (exercise 6).
b)
S4=30.25[f(1)+4f(1.25)+2f(1.5)+4f(1.75)+f(2)]=30.25[1+3.2+1.3333333+2.2857143+0.5]=0.0833333×8.3190476=0.6932540. Error: ∣0.6932540−0.6931472∣=0.0001068. Compared with T4, whose error was 0.0038766: Simpson is about 36 times more accurate, using exactly the SAME five function values. Only the coefficients change. This is why Simpson's rule is the default method whenever there is a choice: for the same computational cost, it gains one or two orders of magnitude.
c)
With n=5, the subintervals cannot be grouped in pairs: a single one would be left at the end, on which no parabola can be built for lack of a third point. The formula simply does not apply, and applying it mechanically would produce an inconsistent pattern of coefficients, hence a wrong result without any warning. This is the most frequent pitfall of the chapter on exams. The student must switch to n=4 or n=6 (one of the two neighbouring even integers), or else use the trapezoidal rule, which imposes no parity condition. Reflex to build: before writing anything for Simpson, check that n is even.
d)
Exact value: ∫02x3dx=[4x4]02=416=4. By Simpson with n=2, so h=1 and the points 0, 1, 2: S2=31[03+4(1)3+23]=31[0+4+8]=312=4 ✓, exactly. The result reveals that Simpson's rule is EXACT for every polynomial of degree at most 3, although it was only built to be exact on parabolas (degree 2). This free extra degree comes from a symmetry cancellation: on each pair of subintervals, the error made on the cubic term on one side exactly cancels the error on the other side. It is precisely this exactness at degree 3 that explains the error bound in f(4) of exercise 6: the method only starts to err from degree 4 on, so the error is governed by the fourth derivative.
Exercise 4: The midpoint rule and the relations between the three methods
The three methods are not independent: their errors are linked by simple ratios, and one of them can be obtained exactly from the other two.
a) For ∫12xdx with n=4, recall that T4=0.6970238 and M4=0.6912199, then compute the two signed errors, given that ln2≈0.6931472.
b) What is the ratio between these two errors? State the general relation and explain it with concavity.
c) Check numerically that 32M4+T4=S8. What is this number?
d) Prove this relation in general. What practical consequence follows when Tn and Mn have already been computed?
Show the solution
Answers
a)+0.0039 and −0.0019
b)ET≈−2EM
c)32M4+T4=S8≈0.693155
d)S2n=3Tn+2Mn: Simpson for free
a)
Trapezoidal error: T4−ln2=0.6970238−0.6931472=+0.0038766, an OVERESTIMATE. Midpoint error: M4−ln2=0.6912199−0.6931472=−0.0019273, an UNDERESTIMATE. The two errors have OPPOSITE signs, which already guarantees a bracket: M4<ln2<T4.
b)
The ratio is −0.0019273+0.0038766≈−2.01, very close to −2. General relation: ET≈−2EM; in other words, the midpoint error is HALF the trapezoidal error, with the opposite sign. Explanation by concavity: the function x1 is convex, so the chord lies above the curve (the trapezoids overestimate) while the tangent line at the midpoint lies below it (the midpoint rule underestimates, because the midpoint rectangle has the same area as the trapezoid built on the tangent line). The factor 2 comes from the error formulas themselves: ET=−12n2f′′(c)(b−a)3 against EM=+24n2f′′(c)(b−a)3 (these formulas count the error as exact value minus estimate, the reverse of the convention used in part a, which does not change the ratio), and 24=2×12. The midpoint rule is therefore TWICE as accurate as the trapezoids for the same number of evaluations, which makes it surprisingly competitive despite its apparent simplicity.
c)
Computation: 32(0.6912199)+0.6970238=31.3824398+0.6970238=32.0794636=0.6931545. And S8=0.6931545 as well: the equality is EXACT, to every decimal place, not approximate. This number is Simpson's estimate with eight subintervals, whose error is only 7.3×10−6.
d)
Proof. Let h=nb−a. Simpson's rule with 2n subintervals uses the n+1 points of the coarse partition AND the n midpoints. Grouping its coefficients 1,4,2,4,…,4,1 (with step 2h), the points of the coarse partition receive the even-position coefficients and the midpoints the coefficients 4. A direct computation gives S2n=6h[f(x0)+f(xn)+2∑interiorf(xi)+4∑midpointsf(mi)], which we recognize as 31Tn+32Mn, that is 3Tn+2Mn ✓. PRACTICAL CONSEQUENCE: if Tn and Mn have already been computed, Simpson with 2n subintervals comes FOR FREE, by a simple weighted average, without a single extra function evaluation. This is the principle of extrapolation: combine two mediocre estimates whose errors have opposite signs and a known ratio to build a much better one. Romberg integration generalizes this idea in a cascade.
Exercise 5: Application: arc length
The arc length formula almost always produces an integral with no elementary antiderivative. It is the most common use of numerical integration in geometry and engineering.
a) Write the integral giving the length of the arc of the parabola y=x2 between x=0 and x=1.
b) Estimate this length with Simpson's rule and n=4.
c) Here, exceptionally, the antiderivative exists. Given that the exact value is 25+4ln(2+5), compute it and give the error.
d) Why do arc length integrals almost always resist exact computation? Bracket the answer to part b) between two obvious geometric lengths.
Show the solution
Answers
a)∫011+4x2dx
b)S4≈1.478978
c)≈1.478943, error ≈3.5×10−5
d)2<L<2
a)
The formula is L=∫ab1+[f′(x)]2dx. Here f(x)=x2 gives f′(x)=2x, so L=∫011+4x2dx.
b)
With h=0.25 and g(x)=1+4x2: g(0)=1; g(0.25)=1.25≈1.118034; g(0.5)=2≈1.414214; g(0.75)=3.25≈1.802776; g(1)=5≈2.236068. So S4=30.25[1+4(1.118034)+2(1.414214)+4(1.802776)+2.236068]=30.25(17.747734)≈1.478978.
c)
Exact value: 25+4ln(2+5)=1.118034+0.360909=1.478943. Simpson's error is therefore ∣1.478978−1.478943∣≈3.5×10−5, a relative accuracy of 0.0024 percent with only five function evaluations. Going to n=8, the error drops to 1.1×10−6, as the order 4 of the method predicts.
d)
Because the formula imposes a SQUARE ROOT of a polynomial: 1+[f′(x)]2. Antiderivatives of such expressions are elementary only in very special cases. As soon as f is a little more complicated than a parabola, you land on so-called elliptic integrals, which are PROVEN to have no elementary antiderivative: this is the case for the perimeter of an ellipse, the length of a sine curve, or a general catenary. The parabola of part a) is a happy exception, which is also why it serves as the example in every textbook. GEOMETRIC BRACKET: the length of the arc is necessarily greater than that of the CHORD joining (0,0) to (1,1), that is 2≈1.414, since the segment is the shortest path; and it is less than the sum of the two sides of the enclosing rectangle, 1+1=2. So 1.414<L<2, and the value 1.479 found fits well ✓. This kind of rough bracket costs ten seconds and immediately catches an error of a factor or of a sign.
Part B: Error, machine precision and singularities (/50)
Exercise 6: Error bounds and the order of convergence
An approximation without an error bound is worthless: it gives a number without saying how far it is from the truth. The two error formulas are the real content of the chapter.
a) State the error bounds for the trapezoidal rule and for Simpson's rule. For f(x)=x1 on [1,2], determine the constants K and M.
b) Compute both bounds for n=4 and check that they do bound the errors actually observed in exercise 2 and exercise 3.
c) Compute T8 and S8. By what factor was each error divided when n was doubled? Relate these factors to the exponents in the formulas.
d) Why do these formulas give a BOUND and not the exact error? What would you need to know to get the exact error, and why do we never have it?
Show the solution
Answers
a)K=2, M=24
b)Bounds 0.0104 and 5.21×10−4: both hold
c)Factors 4 and about 16: orders 2 and 4
d)The point c exists but is not known
a)
Bounds: ∣ET∣≤12n2K(b−a)3 with K≥∣f′′∣ on [a,b], and ∣ES∣≤180n4M(b−a)5 with M≥f(4). For f(x)=x−1: f′=−x−2, f′′=2x−3, f′′′=−6x−4, f(4)=24x−5. On [1,2], these two functions decrease in absolute value, so their maximum is reached at x=1: K=∣f′′(1)∣=2 and M=f(4)(1)=24. Always look for the maximum of the ABSOLUTE value over the interval, not the value at some arbitrary point.
b)
Trapezoids, n=4, b−a=1: ∣ET∣≤12×162×1=1922=0.0104167. Actual error observed: 0.0038766≤0.0104167 ✓. Simpson, n=4: ∣ES∣≤180×25624×1=4608024=0.0005208. Actual error: 0.0001068≤0.0005208 ✓. Both bounds hold, and they are pessimistic by a factor of 3 to 5, which is normal and desirable: a bound must guarantee, not predict.
c)
With n=8 (so h=0.125): T8=0.6941219, with error 0.0009747; and S8=0.6931545, with error 0.0000073. Reduction factors: for the trapezoids, 0.00097470.0038766≈3.98, that is 4; for Simpson, 0.00000730.0001068≈14.5, that is about 16. These factors can be read directly from the formulas: the trapezoidal error goes like n21, so doubling n divides it by 22=4; Simpson's error goes like n41, so it is divided by 24=16. The trapezoidal rule is said to be of ORDER 2 and Simpson's rule of ORDER 4. Decisive practical consequence: to gain one more significant figure, you must roughly triple n with the trapezoids, but only multiply it by 1.8 with Simpson.
d)
They are bounds because an unknown quantity is replaced by its worst case. The exact theorems state that there EXISTS a point c∈[a,b] such that ET=−12n2f′′(c)(b−a)3, and likewise for Simpson with f(4)(c). The problem is that the theorem guarantees that this c exists without locating it: we do not know where it is. Without it, we bound ∣f′′(c)∣ by the maximum K over the whole interval, which turns a useless equality into a usable inequality. To get the exact error you would therefore need c; but if you knew it, you would also know the exact value of the integral, and the approximation would serve no purpose. The reasoning is the same as for the Mean Value Theorem of differential calculus, and for the Taylor remainder: an inaccessible piece of information is traded for a computable guarantee.
Exercise 7: Choosing n for a required accuracy
The most discriminating exam format of the chapter: you are not asked to approximate the integral, you are asked HOW MANY subintervals guarantee an accuracy fixed in advance. The direction of the inequality must be under control.
a) How many subintervals does the trapezoidal rule require to guarantee an error less than 10−4 for ∫12xdx?
b) Same question for Simpson's rule. Watch out for the parity condition.
c) Compare the two answers and comment on the computational cost.
d) A student finds n=40.8 and rounds to n=40. Why is this a mistake, and what should be done instead?
Show the solution
Answers
a)n=41
b)n=8 (even)
c)42 evaluations against 9
d)Always round up
a)
We require ∣ET∣≤12n2K(b−a)3<10−4 with K=2 and b−a=1, that is 12n22<10−4, or 6n21<10−4, so n2>6104=1666.67, so n>40.82. Since n is an integer, we need n≥41: take n=41. Check of the bound: 12×16812=9.91×10−5<10−4 ✓.
b)
We require 180n4M(b−a)5<10−4 with M=24, that is 180n424<10−4, so n4>18024×104=1333.33, so n>6.04. The next integer would be 7, but n must be EVEN for Simpson: so take n=8. Check: 180×409624=3.26×10−5<10−4 ✓. Note in passing that n=6 would not be enough, since 180×129624=1.03×10−4, very slightly above the threshold: rounding up to the next even integer is not an unnecessary precaution, here it is the difference between guaranteeing and not guaranteeing.
c)
Trapezoids: 41 subintervals, so 42 evaluations of f. Simpson: 8 subintervals, so 9 evaluations. Simpson needs about FIVE TIMES fewer computations for the same guaranteed accuracy. The gap widens as the requirement gets stricter: for an error less than 10−8, the trapezoids would need n=4083 while Simpson would settle for n=62, a ratio of 66 instead of 5. This is the concrete meaning of the difference between order 2 and order 4, and it is the reason why no serious software uses the trapezoids when Simpson is available.
d)
It is a mistake because the condition obtained is n>40.82, a STRICT inequality pointing up: rounding to 40 gives an n that does NOT satisfy the condition, and the required accuracy is then no longer guaranteed. Direct check: with n=40, the bound is 12×16002=1.042×10−4>10−4, it does exceed the threshold. You must therefore round UP to the next integer, here 41, and not to the nearest integer. The general rule of the chapter: in a computation of n that guarantees an accuracy, ALWAYS round up, then move up to the next even integer if the method is Simpson's. Taking a larger n than necessary only costs computing time; taking one that is too small invalidates the guarantee, which is the only thing the exercise asked you to produce.
Exercise 8: The two real situations
The previous exercises dealt with an integral whose exact answer was known, so that the error could be measured. Here are the two cases where numerical integration is no longer an exercise but a necessity.
a) Estimate ∫01e−x2dx with Simpson's rule and n=4. Why is the Fundamental Theorem useless here?
b) A sensor records the speed of a vehicle (in m/s) every 2 seconds: 0; 5; 12; 18; 21; 22; 22.5. Estimate the distance travelled with the trapezoidal rule, then with Simpson's rule.
c) For the data in part b), can an error bound be given? Justify.
d) Summarize: faced with an integral to evaluate, which questions should you ask, and in what order, to decide between an exact method, a Taylor series and numerical integration?
Show the solution
Answers
a)S4≈0.74686
b)178.5 m and 179.0 m
c)No: no formula, no derivative
d)Antiderivative, then series or numerical, then numerical only
a)
With h=0.25 and f(x)=e−x2: f(0)=1; f(0.25)=e−0.0625=0.9394131; f(0.5)=e−0.25=0.7788008; f(0.75)=e−0.5625=0.5697829; f(1)=e−1=0.3678794. So S4=30.25[1+4(0.9394131)+2(0.7788008)+4(0.5697829)+0.3678794]=30.25×8.9622646=0.7468554. The true value is 0.7468241: the estimate is correct to within 3×10−5. The Fundamental Theorem is useless because e−x2 has NO elementary antiderivative: it is not that we cannot find it, it is proven that none exists among the usual functions. Yet this integral is one of the most important in science, since it gives the probabilities of the normal distribution; the normal tables of your statistics courses were built exactly this way, by numerical integration.
b)
There are 7 readings, so n=6 subintervals of width h=2 s (and n is even, so Simpson applies). Trapezoids: T6=22[0+2(5+12+18+21+22)+22.5]=1×[0+2(78)+22.5]=178.5 m. Simpson: S6=32[0+4(5)+2(12)+4(18)+2(21)+4(22)+22.5]=32[0+20+24+72+42+88+22.5]=32×268.5=179.0 m. The two estimates of the distance travelled in 12 seconds are therefore 178.5 m and 179.0 m, in agreement to within 0.3 percent. The principle used is that distance is the integral of speed, d=∫012v(t)dt.
c)
NO, not with the formulas of this chapter. Both error bounds involve max∣f′′∣ or maxf(4), and here we have no FORMULA for v(t): only seven numbers. So we can neither differentiate the function, nor even claim that it is four times differentiable, nor know what it does BETWEEN two readings (the vehicle may have braked hard at t=3 s without the data showing it). This is an important limitation, often passed over in silence: numerical integration of experimental data gives an estimate with no mathematical guarantee. The only way to quantify the uncertainty would be statistical or physical, relying on the precision of the sensor and on an assumption about how smooth the motion is, not on the theorems of this chapter. In practice, the gap between the results of two different methods (here 0.5 m) serves as an empirical indicator, without being a proof.
d)
The order of the questions. 1) Is an elementary ANTIDERIVATIVE within reach, possibly after substitution, integration by parts or partial fractions? If so, the Fundamental Theorem gives the EXACT value, and it is always the best answer. 2) If not, is there a FORMULA for f? If so, two options: the Taylor SERIES expansion integrated term by term, which gives a value as accurate as you want with control of the remainder (the method seen in the chapter on power series), or NUMERICAL INTEGRATION, with Simpson by default and a computable error bound. The choice between the two is a matter of convenience: the series is excellent near the centre of the expansion, the numerical method does not care. 3) Do we only have DATA? Then only numerical integration applies, with no mathematical error bound, and Simpson is preferred if the number of subintervals is even, the trapezoids otherwise. The course follows exactly this order, from the most exact to the most general: this chapter is the last resort, and that is precisely why it is the most used outside the classroom.
Exercise 9: The precision floor: how low can you go?
The error formulas promise arbitrary accuracy provided n is large enough. The machine, for its part, stores only about fifteen digits, and that eventually shows.
a) For ∫12xdx, the observed trapezoidal error is 6.25×10−4 for n=10, 6.25×10−6 for n=102 and 6.25×10−8 for n=103. Does this behaviour agree with the theory?
b) The error is 6.25×10−14 for n=106 and 6.7×10−16 for n=107. Does the second figure still follow the law? What is happening?
c) Given that the precision of a number in a computer is about 2.2×10−16, explain why it is USELESS to push n beyond 107 here.
d) The theoretical error decreases, the computational cost increases. How do you choose n in practice? Compare with what Simpson would allow.
Show the solution
Answers
a)Yes: a factor of 100 for each tenfold increase
b)The machine's round-off floor
c)Nothing to gain below ≈10−16
d)Smallest useful n; Simpson n=44 for 10−8
a)
Yes, perfectly. The trapezoidal bound goes like n21, so multiplying n by 10 should divide the error by 102=100. The observed values confirm it exactly: 6.25×10−4, then 6.25×10−6, then 6.25×10−8, a factor of 100 each time. The coefficient 6.25×10−2 stays constant, which means that the error is approximately n20.0625. One can also check consistency with the theoretical bound 12n2K(b−a)3=12n22≈n20.167: the actual error is about 2.7 times smaller than the bound, which is normal, since a bound is made to guarantee and not to predict.
b)
No, the law stops being followed. Going from n=106 to n=107, the error should be divided by 100, so drop from 6.25×10−14 to about 6.25×10−16. It actually drops to 6.7×10−16, which is still close, but any further progress becomes impossible: at n=108 the computed error is zero, not because the result is exact, but because the resolution of the machine has been reached. What is happening is that the TRUNCATION error (the one in the formulas, in n21) has come down to the level of the ROUND-OFF error, which comes from storing numbers in floating point and from accumulating millions of additions.
c)
A real number is stored in a computer with about 16 significant figures, a relative precision of 2.2×10−16. Since the value sought, ln2≈0.693, is of order 1, no method can deliver a result more accurate than a few times 10−16 in absolute value: it is an impassable FLOOR, independent of the formula used. And at n=107 we are already there. Going further would multiply the computing time by 10, 100, 1000, without ever gaining a single correct digit. Worse, the sum of 108 terms itself accumulates round-off, so that beyond a certain point the accuracy can actually GET WORSE. The error formula, for its part, naively promises infinite accuracy: it describes exact mathematics, not machine arithmetic.
d)
In practice, choose the smallest n that reaches the accuracy ACTUALLY needed, never the largest possible. A physical measurement is rarely known to better than four digits, so aiming for 10−6 is already generous, and n of the order of a few hundred is more than enough with the trapezoids. The comparison with Simpson is telling: to reach 10−8, the trapezoids need n≈2500 while Simpson settles for n=44, its actual error being about n40.03, nearly 60 times fewer evaluations. And since Simpson is of order 4, it hits the machine floor with a few thousand points where the trapezoids need tens of millions. The practical rule is therefore twofold: choose the method of highest order available, then the smallest n that meets the need, and remember that below about 10−15, no refinement of the method helps any more.
Exercise 10: Singularities: when the error bound is worth nothing
All the bounds of the chapter assume that f′′ or f(4) is BOUNDED. With a convergent improper integral, that assumption fails, and every guarantee goes with it.
a) The integral ∫01xdx converges and equals 2. Why can the trapezoidal rule not be applied as it stands?
b) The MIDPOINT rule, on the other hand, does apply. The values obtained are 1.8089 for n=10, 1.9395 for n=100, 1.9809 for n=1000 and 1.9940 for n=104. By what factor is the error divided with each tenfold increase?
c) Compare this behaviour with the expected order 2. Which assumption of the error bounds is violated?
d) Suggest a remedy by a change of variable, and show that it makes the problem trivial.
Show the solution
Answers
a)f(0) does not exist
b)Factor 10≈3.16
c)Convergence like n−1/2: f′′ unbounded
d)x=u2: ∫012du=2
a)
The trapezoidal rule requires evaluating the function at BOTH endpoints, but f(0)=01 does not exist: the function tends to +∞ at 0. The computation stops on a division by zero. This is a structural flaw of the so-called CLOSED rules, those that use the endpoints of the interval, and it affects Simpson's rule as well.
b)
Successive errors: 2−1.8089=0.1911; 2−1.9395=0.0605; 2−1.9809=0.0191; 2−1.9940=0.0060. Ratios: 0.06050.1911≈3.16; 0.01910.0605≈3.16; 0.00600.0191≈3.16. The error is therefore divided by only about 3.16, that is 10, each time n is multiplied by 10.
c)
The expected order 2 would mean a division by 102=100 with each tenfold increase; we observe 10≈3.16, which corresponds to convergence like n−1/2 only. The method is therefore DRAMATICALLY slower than promised: to gain a single decimal digit, n must be multiplied by 100, and reaching 10−6 would require n≈1012, which is out of reach. The violated assumption concerns the DERIVATIVE: the bound ∣EM∣≤24n2K(b−a)3 assumes there is a K bounding ∣f′′∣ over the whole interval. But f(x)=x−1/2 gives f′′(x)=43x−5/2, which tends to +∞ as x→0+: no finite K exists, the bound is EMPTY, and it says strictly nothing. The method still converges, but nothing guarantees how fast any more, and the observation shows that it is much more slowly.
d)
Remedy: the change of variable x=u2, with dx=2udu and x=u. The bounds become u=0 and u=1, and the integral turns into ∫01u2udu=∫012du=2. The singularity has DISAPPEARED: the new integrand is the constant 2, perfectly regular. The integral is then computed exactly, and any numerical method would get it right to the last digit, including the trapezoids with n=1, since all the methods of the chapter are exact for constants. The general lesson matters: faced with an improper integral, the right reflex is not to refine the numerical method, but first to remove the singularity with a suitable change of variable, or to split off the problematic part analytically. Forcing a singularity through numerically is the surest way to compute for a long time and get very little.
Part C: The classics (/50)
Exercise 11: Bracketing an integral between the left and right rectangles
We want to estimate I=∫01ex2dx, whose antiderivative is not elementary. The function f(x)=ex2 is increasing on [0,1], which gives a guaranteed bracket without any derivative.
a) Compute L4 and R4, the left and right rectangle sums with n=4.
b) Justify that L4≤I≤R4.
c) Show that Rn−Ln=nf(1)−f(0) for every n, and compute this gap for n=4.
d) How many subintervals are needed for the bracket to be narrower than 0.01?
e) The average 2L4+R4 is the trapezoidal rule. Compute it and compare with the value I≈1.46265. Does it overestimate or underestimate, and why?
Show the solution
Answers
a)L4≈1.27589, R4≈1.70546
b)f increasing: L4≤I≤R4
c)Rn−Ln=ne−1; 0.42957
d)n=172
e)T4≈1.49068, overestimates (f convex)
a)
h=0.25. Values: f(0)=1, f(0.25)=e0.0625≈1.064494, f(0.5)=e0.25≈1.284025, f(0.75)=e0.5625≈1.755055, f(1)=e≈2.718282. L4=0.25(1+1.064494+1.284025+1.755055)≈1.27589 and R4=0.25(1.064494+1.284025+1.755055+2.718282)≈1.70546.
b)
On each subinterval [xi−1,xi], the increasing function f satisfies f(xi−1)≤f(x)≤f(xi). Integrating: hf(xi−1)≤∫xi−1xif≤hf(xi). Summing, L4≤I≤R4. The bracket is certain, with no error bound to compute.
c)
Rn and Ln share the values f(x1),…,f(xn−1); in addition, Rn contains f(xn)=f(1) and Ln contains f(x0)=f(0). So Rn−Ln=h(f(1)−f(0))=ne−1. For n=4: 41.718282≈0.42957, which is indeed 1.70546−1.27589.
d)
ne−1<0.01 gives n>171.8, so n=172. The guarantee is simple but costly: the error only decreases like n1, and the midpoint of the bracket is then within 0.005 of I.
e)
T4=21.27589+1.70546≈1.49068, an error of about +0.028. It OVERESTIMATES, because f′′(x)=(2+4x2)ex2>0: f is convex and each chord lies above the curve. With a single extra computation, the average has divided the error by almost 7 compared with L4.
Exercise 12: The length of a sine arch: when the trapezoids beat Simpson
The length of the arch y=sinx on [0,π] is L=∫0π1+cos2xdx, an elliptic integral with no elementary antiderivative. Its value, obtained with a very large n, is L≈3.820198.
a) Bracket L between two geometric lengths: the polygonal path through (0,0), (2π,1) and (π,0), and a path longer than the arch.
b) Compute T4 with h=4π.
c) Compute S4 with the same five values.
d) Compare the two errors. Which method wins here, against all expectations?
e) Explain this result by the periodicity of the integrand g(x)=1+cos2x.
Show the solution
Answers
a)3.724<L<5.142
b)T4≈3.819944
c)S4≈3.829179
d)Errors −0.00025 against +0.0090: the trapezoids win
e)Periodic integrand over one period
a)
The polygonal path is shorter than the arch, which it joins at three of its points: 24π2+1≈3.724. The arch is shorter than the path that rises by 1, moves forward by π and comes back down by 1: π+2≈5.142. So 3.724<L<5.142.
Trapezoidal error: 3.819944−3.820198≈−0.00025. Simpson error: 3.829179−3.820198≈+0.0090, thirty-five times larger. The trapezoids win clearly, even though Simpson is of higher order.
e)
g is periodic with period π, and the interval of integration covers exactly one period. For a smooth function integrated over a full period, the trapezoidal errors at the two ends cancel exactly, and the method converges much faster than the bound in n21 announces. Simpson, which weights the points unequally (4 and 2), destroys this symmetry. The order of a method describes the worst case, not every integral: over one period, the trapezoids are the method of choice.
Exercise 13: Closed rules and the midpoint rule on a concave function
We study I=∫14xdx=314≈4.666667 with n=3 subintervals of width h=1. The square root function is concave, and the order of the estimates will be reversed compared with a convex function.
a) Compute T3.
b) Compute M3.
c) Put T3, M3 and I in increasing order and justify this order by concavity.
d) Compute the ratio of the errors M3−IT3−I and compare with the theoretical value.
e) Compute 3T3+2M3. Why is this combination so good, and why is it NOT Simpson's rule applied with n=3?
T3≈4.6463<I≈4.6667<M3≈4.6767. The square root is concave: the chord lies BELOW the curve, so the trapezoids underestimate, and the tangent line at the midpoint lies ABOVE it, so the midpoint rule overestimates. This is the reverse of the order observed for x1, which is convex.
d)
T3−I≈−0.020403 and M3−I≈+0.010045: the ratio is about −2.03, close to the theoretical value −2. The agreement is not perfect because f′′(x)=−41x−3/2 varies a lot on [1,4] and n=3 is small.
e)
34.646264+2×4.676712≈4.666563, within 1.0×10−4 of I, two hundred times better than T3. The combination is built to cancel the leading term of the errors, which are in the ratio −2. It equals Simpson with n=6 subintervals of width 21, using the seven points 1, 1.5, 2, …, 4: it is S6, and not a Simpson with three subintervals, which does not exist since 3 is odd.
Exercise 14: Problem: the cross-sectional area of a river and its flow rate
To measure the flow rate of a river 16 m wide, the depth is recorded every 2 m from one bank to the other. The mean speed of the current in the cross-section is also measured: 0.8 m/s.
a) The depths recorded, in metres, are 0, 1.2, 2.1, 2.6, 2.8, 2.5, 1.9, 1.0, 0. How many subintervals, and how wide? Does Simpson's rule apply?
b) Estimate the cross-sectional area with the trapezoidal rule.
c) Estimate it with Simpson's rule.
d) Deduce the flow rate of the river with Simpson's estimate, in m3/s, then the volume that flows past in one hour.
e) The reading at 4 m from the left bank (2.1 m) was a misreading: the true depth is 2.4 m. By how much does each area estimate change? Why does Simpson react less here?
Show the solution
Answers
a)n=8, h=2 m: Simpson applies
b)T8=28.2 m2
c)S8≈28.53 m2
d)Q≈22.83 m3/s; ≈82000 m3 per hour
e)+0.6 against +0.4 m2: even-index coefficient in Simpson
a)
Nine readings give n=8 subintervals of width h=2 m. n is even: Simpson applies. We integrate the depth p(x) across the width: the cross-sectional area is ∫016p(x)dx.
Flow rate Q=28.53×0.8≈22.83 m3/s. In one hour: 28.533×0.8×3600≈82180 m3, about 82000 m3. The two methods differ by only 0.33 m2, a little over one percent: the real accuracy is limited by the measurements, not by the method.
e)
The point at 4 m has index 2, which is even: it gets the coefficient 2 in Simpson and 2 in the trapezoids. Trapezoids: the area increases by 2h×2×0.3=0.6 m2. Simpson: by 3h×2×0.3=0.4 m2. Simpson reacts less to this point because it gives the heavy weight, 4, to the points with an odd index and a reduced weight to the points with an even index; a point with an odd index would on the contrary have weighed 3h×4×0.3=0.8 m2. So the ratio of the reactions is not the same in every case: it depends on the parity of the index.
Exercise 15: Problem: the period of a pendulum at large amplitudes
A simple pendulum of length ℓ released from rest at an angle θ0 has period T=4gℓK(k), with k=sin2θ0 and K(k)=∫0π/21−k2sin2φdφ, an elliptic integral with no elementary antiderivative. For small angles, we use T0=2πgℓ.
The figure below shows the situation; it is not to scale.
a) Check that for k=0, the formula gives back T0.
b) For θ0=60°, compute k, then estimate K(k) with Simpson's rule and n=4.
c) Deduce the ratio T0T. By what percentage does the small-angle formula underestimate the period?
d) For ℓ=1 m and g=9.81 m/s2, compute T0 and T.
e) For θ0=90°, the precise value is K≈1.8541. Compute the ratio T0T and comment on the use of the small-angle formula in a clock.
Show the solution
Answers
a)K(0)=2π gives T0
b)k=21; S4≈1.68574
c)T0T≈1.0732: 7.3 %
d)T0≈2.006 s, T≈2.153 s
e)≈1.1803: an 18 % gap
a)
For k=0, the integrand equals 1 and K(0)=2π. So T=4gℓ×2π=2πgℓ=T0 ✓.
b)
k=sin30°=21, k2=41. With h=8π and u(φ)=1−0.25sin2φ1: u(0)=1, u(8π)≈1.018797, u(4π)≈1.069045, u(83π)≈1.122851, u(2π)≈1.154701. S4=24π[1+4(1.018797)+2(1.069045)+4(1.122851)+1.154701]≈24π×12.878383≈1.685742. The precise value is 1.685750: five points are enough for five correct digits, since the integrand is very smooth.
c)
T0T=2π4K=π2K≈π2×1.68575≈1.0732. The actual period is 7.3 percent longer: the small-angle formula underestimates it by that much.
d)
9.811≈0.319275. T0=2π×0.319275≈2.006 s and T=4×0.319275×1.68575≈2.153 s. The gap, 0.15 s per oscillation, adds up to about four minutes in one hour, since an hour holds some 1700 oscillations.
e)
π2×1.8541≈1.1803: an 18 percent gap. The small-angle formula is therefore valid only at small angles: a pendulum clock swings with an amplitude of a few degrees, where the gap falls below one part in a thousand, and above all with a CONSTANT amplitude, otherwise the period would drift as the mainspring runs down.
Something missing from this set?A type of exercise your teacher gives, a problem you are stuck on, 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.
Looking for an integral calculus tutor in Montreal?
Get in touch for a first session. We work on integral calculus at the real level of the tests, numerical integration and its error bounds included, a chapter often rushed at the end of the term.