h=42−0=0.5. Nodes and heights:
x=0,0.5,1,1.5,2⇒f=1,1.25,2,3.25,5.T4=2h[f(x0)+f(x4)+2(f(x1)+f(x2)+f(x3))]=20.5[1+5+2(1.25+2+3.25)]=0.25[6+2(6.5)]=0.25⋅19=4.75.
Exact value: ∫02(x2+1)dx=38+2=4.66. Trapezoid overshoots (curve is convex, straight lids sit above it) by ≈0.083.
Recall Solution
Same nodes/heights as L2.1. Weights [1,4,2,4,1]:
S4=3h[1+4(1.25)+2(2)+4(3.25)+5]=30.5[1+5+4+13+5]=30.5⋅28=4.66.
This equals the exact 14/3exactly, because x2+1 is degree 2 and Simpson integrates all parabolas exactly.
n=4 (h=0.25), nodes 0,0.25,0.5,0.75,1, f=1,1.284025,1.648721,2.117000,2.718282:
T4=20.25[1+2.718282+2(1.284025+1.648721+2.117000)]=0.125⋅14.817774=1.852222.
Wait—recompute the bracket carefully: 1+2.718282=3.718282; interior sum =1.284025+1.648721+2.117000=5.049746, doubled =10.099492; total =13.817774; ×0.125=1.727222. Error E4=1.727222−1.718282=0.008940.
Ratio E2/E4=0.035649/0.008940≈3.99≈4. ✓ The O(h2) prediction holds.
Recall Solution
Why: The error of fitting a parabola to a cubic comes from the leftover cubic term. On the symmetric interval [−h,h] the cubic error term is an odd function of x, and the integral of an odd function over symmetric limits is 0. The Simpson nodes −h,0,h are symmetric, so the odd leftover integrates to exactly zero — the cubic term contributes nothing to the error. That is the "free" extra degree.
Confirm: true value ∫−11x3dx=0 (odd function). Simpson with h=1, f(−1)=−1,f(0)=0,f(1)=1:
S=31[(−1)+4(0)+1]=31⋅0=0.
Exact, as promised. ✓
Richardson combine:
S=34(4.75)−5=319−5=314=4.66.
This matches S4=4.66 exactly. Why it works: trapezoid error is Ch2+O(h4). Halving h scales the leading term by 41; the weights 4 and −1 over 3 are chosen precisely so the h2 terms cancel, leaving a method accurate to O(h4) — which is Simpson. This is one step of Richardson extrapolation; iterating it gives Romberg integration.
Recall Solution
h=0.2, nodes xi=0,0.2,0.4,0.6,0.8,1.0, heights
f=1,1.221403,1.491825,1.822119,2.225541,2.718282.Simpson on [0,0.8] (nodes x0..x4, weights 1,4,2,4,1):
S=30.2[1+4(1.221403)+2(1.491825)+4(1.822119)+2.225541]
Bracket =1+4.885612+2.983650+7.288476+2.225541=18.383279; ×30.2=1.225552.Trapezoid on [0.8,1.0] (nodes x4,x5):
T=20.2[2.225541+2.718282]=0.1⋅4.943823=0.494382.Total=1.225552+0.494382=1.719934. Error ≈0.00165 — much better than pure trapezoid, honestly handling the dangling slice.
Trapezoid exact: any straight line, e.g. f(x)=3x+1 on [0,4]. Trapezoid is exact for degree-1 polynomials by construction (a straight lid is the function). Exact value ∫04(3x+1)dx=23(16)+4=28; with n=1, T1=24[f(0)+f(4)]=2[1+13]=28. ✓ Simpson also gives 28 but buys you nothing extra — there is no curvature to capture.
Error orders fail: take f(x)=x on [0,1]. Its derivative blows up at x=0, so the Taylor-series argument behind O(h2)/O(h4) (which needs bounded higher derivatives) breaks down. The observed convergence is slower than h2. Lesson: the advertised error orders assume f is smooth enough (bounded 2nd derivative for trapezoid, 4th for Simpson). Kinks, cusps, and singularities void the guarantee — reach for scipy.integrate.quad's adaptive machinery there.
Recall Solution
Correct (weights 1,4,1): 31[0+4(1)+4]=38=2.6667. Exact ✓.
Buggy (weights 4,4,4): 31[4(0)+4(1)+4(4)]=31[0+4+16]=320=6.6667.
Error from the bug=6.6667−2.6667=4.0000 — a wildly wrong answer (2.5× too big). The extra weight on x2=2 (where f=4) alone added 31⋅3⋅4=4. This is why endpoint weighting is the #1 silent bug: it doesn't crash, it just quietly returns garbage.
Recall Solution
S4 (h=0.25, nodes 0,0.25,0.5,0.75,1, f=0,0.00390625,0.0625,0.31640625,1):
S4=30.25[0+4(0.00390625)+2(0.0625)+4(0.31640625)+1]
Bracket =0+0.015625+0.125+1.265625+1=2.40625; ×30.25=0.200521.
Error E4=0.200521−0.2=0.000521 — small but nonzero (degree 4 exceeds Simpson's exact degree 3).
S8 (h=0.125): computing the weighted sum gives S8=0.20003255, error E8≈0.00003255.
Ratio E4/E8≈0.000521/0.00003255≈16.0=24. ✓ The O(h4) order is confirmed.
Recall Self-test summary (cloze)
The slice width is ==h=(b−a)/n.
Simpson's per-pair stencil is 1-4-1, scaled by h/3==.
Trapezoid error order ::: O(h2)
Simpson error order ::: O(h4)
Highest exact degree — trapezoid / Simpson ::: 1 / 3
Points for n subintervals ::: n+1
Richardson combo giving Simpson from trapezoids ::: S=(4T(h/2)−T(h))/3