Chapter 22 Self-Check Quiz: Numerical Integration and Differentiation
Twenty questions to test whether the chapter stuck. Answer from memory, then check the key at the end. Target: 16/20. Below that, the "Topics to review by question" map at the bottom tells you exactly which section to revisit. No compiler needed — every "what prints" item is hand-computable.
1. (MC) The central difference $\big(f(x+h) - f(x-h)\big)/(2h)$ has order of accuracy: a) $O(h)$ b) $O(h^2)$ c) $O(h^3)$ d) $O(h^4)$
2. (MC) The forward difference's truncation error, from the Taylor expansion, has leading term: a) $\tfrac{h}{2}f''(x)$ b) $\tfrac{h^2}{6}f'''(x)$ c) $\tfrac{h^2}{12}f^{(4)}(x)$ d) $h\,f'(x)$
3. (T/F + justify) Simpson's rule integrates any cubic polynomial exactly.
4. (MC) An $n$-point Gauss-Legendre rule is exact for all polynomials up to degree: a) $n$ b) $n+1$ c) $2n-1$ d) $2n+1$
5. (Short answer) You halve the step $h$ and the error of a method drops by a factor of $16$. What is its order of accuracy $p$, and which rule from this chapter is it?
6. (MC) The three-point second difference $\big(f(x+h) - 2f(x) + f(x-h)\big)/h^2$ approximates: a) $f'(x)$, order $O(h)$ b) $f''(x)$, order $O(h^2)$ c) $f''(x)$, order $O(h^4)$ d) $\int f$, order $O(h^2)$
7. (What prints?) For $f(x) = x^2$:
print '(f6.2)', (sq(2.0_dp + 0.5_dp) - sq(2.0_dp)) / 0.5_dp ! forward diff at x=2, h=0.5
What is printed, and what is the exact $f'(2)$?
8. (T/F + justify) Making $h$ as small as the machine allows always makes a finite-difference derivative more accurate.
9. (MC) The round-off floor in numerical differentiation comes from: a) overflow b) subtracting nearly equal values (catastrophic cancellation) c) integer division d) underflow to zero
10. (Short answer) Why does numerical integration not suffer the round-off floor that numerical differentiation does?
11. (What prints?) Trapezoidal rule on $\int_0^1 x\,dx$ with $n = 2$:
! h = 0.5; s = 0.5*(f(0)+f(1)) + f(0.5); s = s*h
What value results, and is it exact?
12. (MC) In pure function trapezoid(f, a, b, n), the dummy f is a procedure(scalar_fn) argument.
For the function to be legal as pure, the interface scalar_fn must be declared:
a) elemental b) pure c) recursive d) impure
13. (Short answer) Write the composite trapezoidal-rule weights (the multipliers on $f_0, f_1, \ldots, f_n$ before multiplying by $h$).
14. (T/F + justify) Two-point Gauss-Legendre uses fewer function evaluations than Simpson's rule yet can be more accurate on a smooth integrand.
15. (What prints?) Simpson's rule on $\int_0^1 x^3\,dx$ with $n = 2$ prints 0.25000000. True or false,
and why?
16. (MC) Richardson extrapolation of two estimates $A(h)$ and $A(h/2)$ from a method of order $p$ combines them as: a) $A(h/2) - A(h)$ b) $\tfrac12\big(A(h) + A(h/2)\big)$ c) $\big(2^p A(h/2) - A(h)\big)/(2^p - 1)$ d) $2A(h/2) - A(h)$
17. (Short answer) A product quadrature rule uses $n$ nodes per dimension. How many function evaluations does it need in $d$ dimensions, and what is this scaling problem called?
18. (MC) Monte Carlo integration's error scales like: a) $O(1/N)$ b) $O(1/\sqrt{N})$ c) $O(1/N^2)$ d) $O(\log N / N)$ — and, crucially, this rate is: independent of / proportional to the dimension $d$ (pick one).
19. (What prints?) For the central difference of $f(x) = x^4$ at $x = 1$ (exact $f'(1) = 4$) with
$h = 0.1$: the estimate is $4 + 4h^2$. What prints under f8.4, and what is the error?
20. (Short answer) You write a new $O(h^2)$ difference operator and want to confirm it before trusting it. Describe the two-line experiment, and what number in the output confirms second order.
Answer Key
| # | Answer | One-line rationale |
|---|---|---|
| 1 | b | Subtracting the Taylor expansions cancels the $f''$ term; leading error is $\tfrac{h^2}{6}f'''$ → $O(h^2)$. |
| 2 | a | $\big(f(x+h)-f(x)\big)/h = f'(x) + \tfrac{h}{2}f''(x) + \cdots$ |
| 3 | True | Simpson fits parabolas; its error $\propto f^{(4)}$, which is $0$ for any cubic — so it is exact to degree 3. |
| 4 | c | Choosing both nodes and weights optimally doubles the reach to degree $2n-1$. |
| 5 | $p = 4$; Simpson's rule | Error ratio $2^p = 16 \Rightarrow p = 4$. |
| 6 | b | Adding the expansions leaves $f''$; leading error $\tfrac{h^2}{12}f^{(4)}$ → $O(h^2)$. |
| 7 | Prints 4.50; exact $f'(2)=4$ |
$(2.5^2 - 2^2)/0.5 = (6.25-4)/0.5 = 4.5$; error $0.5 = h$ (forward, $O(h)$). |
| 8 | False | Below $h^*\!\sim\!\sqrt\varepsilon$ (forward), cancellation makes it worse — the round-off floor. |
| 9 | b | $f(x+h)$ and $f(x)$ agree in most digits; their difference loses them (Chapter 20). |
| 10 | Integration adds, never subtracts near-equals | No cancellation, so shrinking $h$ keeps improving (sum round-off grows only like $\sqrt{n}\varepsilon$). |
| 11 | 0.5, and exact |
$s = 0.5(f(0)+f(1)) + f(0.5) = 0.5(0+1)+0.5 = 1.0$; then $s\cdot h = 1.0\cdot0.5 = 0.5$; trapezoid is exact for linear $f$. |
| 12 | b | A pure procedure may only call pure procedures, so the dummy must be pure via its interface. |
| 13 | $\tfrac12, 1, 1, \ldots, 1, \tfrac12$ | Interior points are shared endpoints of two panels (full weight); the two ends get half. |
| 14 | True | Gauss-2 (2 evals) is exact to degree 3; Simpson (3 evals) is also exact to degree 3 but places points worse for higher degree. |
| 15 | True | Simpson is exact for cubics ($f^{(4)}=0$), so $\int_0^1 x^3 = \tfrac14$ comes out exactly. |
| 16 | c | $\big(2^p A(h/2) - A(h)\big)/(2^p-1)$ cancels the $h^p$ error term. |
| 17 | $n^d$ evaluations; the curse of dimensionality | Product grids grow exponentially in $d$. |
| 18 | b, and independent of $d$ | $O(1/\sqrt N)$, dimension-independent — why it beats grids in high $d$. |
| 19 | Prints 4.0400; error $0.04$ |
$4 + 4(0.1)^2 = 4.04$; error $4h^2 = 0.04$ ($O(h^2)$). |
| 20 | Compute the error at $h$ and $h/2$; take the ratio | A ratio of $4$ (i.e. $2^p$ with $p=2$) confirms second order. |
Topics to review by question
- Q1, Q2, Q6, Q7, Q19 — §22.1 (finite differences, Taylor-derived orders).
- Q3, Q11, Q13, Q15 — §22.2 (trapezoidal and Simpson's rules).
- Q4, Q14 — §22.3 (Gaussian quadrature).
- Q5, Q16, Q20 — §22.3–§22.4 (Richardson, measuring order of accuracy).
- Q8, Q9, Q10 — §22.4 (round-off floor; the Chapter 20 connection).
- Q17, Q18 — §22.5 (multidimensional integration, curse of dimensionality, Monte Carlo).
- Q12 — §22.2 + Chapter 6 (
pureprocedure arguments).
If you scored below 16, the most common weak spots are the orders (Q1–Q6) and the round-off floor (Q8–Q10). Re-read the 🚪 Threshold Concept in §22.1 and the ⚠️ Common Pitfall in §22.4, then retake.