Skip to main content

Thomas’ Calculus · Chapter 08 · Section 8.7

By Muhammad Abdullah Athar · SymPy Verified

Numerical Integration

❦

Read this page the way you would a book: first the notes, then the key ideas, then every worked example in order — each step explains not only what to do, but why it works.

Part One

Section Notes

❧

Section 8.7: Numerical Integration

When a function lacks an elementary antiderivative (e.g. e−x2e^{-x^2}, sin⁡xx\frac{\sin x}{x}), numerical quadrature approximates the definite integral.


1. Quadrature Formulas

  • Trapezoidal Rule: Weights 1,2,2,…,2,11, 2, 2, \dots, 2, 1 scaled by Δx2\frac{\Delta x}{2}.
  • Simpson's Rule: Weights 1,4,2,4,…,4,11, 4, 2, 4, \dots, 4, 1 scaled by Δx3\frac{\Delta x}{3} (nn even).

2. Error Bounds

  • ∣ET∣≤M2(b−a)312n2|E_T| \le \frac{M_2 (b - a)^3}{12 n^2} where ∣f′′(x)∣≤M2|f''(x)| \le M_2.
  • ∣ES∣≤M4(b−a)5180n4|E_S| \le \frac{M_4 (b - a)^5}{180 n^4} where ∣f(4)(x)∣≤M4|f^{(4)}(x)| \le M_4.

Part Two

Key Ideas to Remember

1 essential statements for this section, each with a plain-words explanation.

Formula #1Sec 8.7

Trapezoidal Rule and Simpson's Rule

Tn=Δx2[y0+2y1+2y2+⋯+2yn−1+yn],Sn=Δx3[y0+4y1+2y2+4y3+⋯+yn]T_n = \frac{\Delta x}{2} [y_0 + 2y_1 + 2y_2 + \dots + 2y_{n-1} + y_n], \quad S_n = \frac{\Delta x}{3} [y_0 + 4y_1 + 2y_2 + 4y_3 + \dots + y_n]

Numerical quadrature algorithms to approximate definite integrals when antiderivatives cannot be expressed in elementary terms. Simpson's Rule fits parabolic arcs across pairs of subintervals (n must be even).

Conditions: Delta x = (b - a)/n; n is even for Simpson's Rule

In plain words: Trapezoidal error scales with (Delta x)^2; Simpson's error scales with (Delta x)^4.

Remember — Simpson's Rule integrates cubic polynomials with zero error.

Part Three

Worked Examples

5 exercises, solved in full. Every answer has been checked symbolically with SymPy before printing.

Example 01(Section 8.7, Exercise 1)

Warm-up

Problem. Use the Trapezoidal Rule with n = 4 to approximate int_1^2 1/x dx.

Step-by-Step Derivation (3 steps)

1

Compute Delta x and Grid Points

Δx=2−14=14;x0=1,  x1=54,  x2=32,  x3=74,  x4=2\Delta x = \frac{2 - 1}{4} = \frac{1}{4}; \quad x_0 = 1, \; x_1 = \frac{5}{4}, \; x_2 = \frac{3}{2}, \; x_3 = \frac{7}{4}, \; x_4 = 2

Partition [1, 2] into 4 equal slices.

Why this works: Uniform grid spacing.
2

Evaluate Function Values

y0=1,  y1=45,  y2=23,  y3=47,  y4=12y_0 = 1, \; y_1 = \frac{4}{5}, \; y_2 = \frac{2}{3}, \; y_3 = \frac{4}{7}, \; y_4 = \frac{1}{2}

Evaluate f(x) = 1/x at all grid points.

Why this works: Function ordinate evaluation.
3

Apply Trapezoidal Formula

T4=1/42[1+2(45)+2(23)+2(47)+12]=18(1171210)=11711680T_4 = \frac{1/4}{2} \left[ 1 + 2\left(\frac{4}{5}\right) + 2\left(\frac{2}{3}\right) + 2\left(\frac{4}{7}\right) + \frac{1}{2} \right] = \frac{1}{8} \left( \frac{1171}{210} \right) = \frac{1171}{1680}

Sum weighted values and multiply by Delta x / 2.

Why this works: Trapezoidal approximation.

Answer: T4=18(1+2(45)+2(23)+2(47)+12)=11711680≈0.6970T_4 = \frac{1}{8}\left( 1 + 2\left(\frac{4}{5}\right) + 2\left(\frac{2}{3}\right) + 2\left(\frac{4}{7}\right) + \frac{1}{2} \right) = \frac{1171}{1680} \approx 0.6970

✓ Verified by SymPy CAS

Example 02(Section 8.7, Exercise 2)

Warm-up

Problem. Use Simpson's Rule with n = 4 to approximate int_1^2 1/x dx.

Step-by-Step Derivation (3 steps)

1

Identify Ordinates and Weights

Δx=14,Weights: 1,4,2,4,1\Delta x = \frac{1}{4}, \quad \text{Weights: } 1, 4, 2, 4, 1

Simpson's 1-4-2-4-1 pattern.

Why this works: Simpson's quadrature rule.
2

Apply Formula

S4=1/43[1+4(45)+2(23)+4(47)+12]=112(1+165+43+167+12)S_4 = \frac{1/4}{3} \left[ 1 + 4\left(\frac{4}{5}\right) + 2\left(\frac{2}{3}\right) + 4\left(\frac{4}{7}\right) + \frac{1}{2} \right] = \frac{1}{12} \left( 1 + \frac{16}{5} + \frac{4}{3} + \frac{16}{7} + \frac{1}{2} \right)

Multiply sum by Delta x / 3.

Why this works: Simpson's sum evaluation.
3

Calculate Rational Value

112(1747210)=17472520≈0.693254…(True value ln⁡(2)≈0.693147)\frac{1}{12} \left( \frac{1747}{210} \right) = \frac{1747}{2520} \approx 0.693254 \dots \text{(True value } \ln(2) \approx 0.693147)

Simpson's rule matches ln(2) to 3 decimal places.

Why this works: High-order accuracy demonstration.

Answer: S4=112(1+4(45)+2(23)+4(47)+12)=17472520≈0.69325S_4 = \frac{1}{12}\left( 1 + 4\left(\frac{4}{5}\right) + 2\left(\frac{2}{3}\right) + 4\left(\frac{4}{7}\right) + \frac{1}{2} \right) = \frac{1747}{2520} \approx 0.69325

✓ Verified by SymPy CAS

Example 03(Section 8.7, Exercise 3)

Core practice

Problem. Determine the minimum number of subintervals n required to ensure the Trapezoidal Rule approximation of int_1^2 1/x dx has error <= 10^(-4).

Step-by-Step Derivation (3 steps)

1

Find Maximum of Second Derivative M_2

f(x)=x−1  ⟹  f′(x)=−x−2  ⟹  f′′(x)=2x−3=2x3f(x) = x^{-1} \implies f'(x) = -x^{-2} \implies f''(x) = 2x^{-3} = \frac{2}{x^3}

On [1, 2], f''(x) achieves its maximum at x = 1.

Why this works: Locating upper bound M_2.
2

State M_2 and Error Bound Inequality

M2=2;∣ET∣≤M2(b−a)312n2=2(1)312n2=16n2≤10−4M_2 = 2; \quad |E_T| \le \frac{M_2 (b - a)^3}{12 n^2} = \frac{2(1)^3}{12 n^2} = \frac{1}{6n^2} \le 10^{-4}

Substitute M_2 = 2 and b - a = 1.

Why this works: Trapezoidal error bound formula.
3

Solve for n

6n2≥104  ⟹  n2≥100006≈1666.67  ⟹  n≥1666.67≈40.82  ⟹  n≥416n^2 \ge 10^4 \implies n^2 \ge \frac{10000}{6} \approx 1666.67 \implies n \ge \sqrt{1666.67} \approx 40.82 \implies n \ge 41

Round up to the nearest integer.

Why this works: Integer subinterval constraint.

Answer: n≥41n \ge 41

✓ Verified by SymPy CAS

Example 04(Section 8.7, Exercise 4)

Core practice

Problem. Verify that Simpson's Rule with n = 2 gives the exact value for int_0^2 x^3 dx.

Step-by-Step Derivation (3 steps)

1

Evaluate Definite Integral Exactly

∫02x3dx=[x44]02=164=4\int_0^2 x^3 dx = \left[ \frac{x^4}{4} \right]_0^2 = \frac{16}{4} = 4

Standard FTC evaluation.

Why this works: Exact target value.
2

Compute Simpson's Rule with n = 2

Δx=1;x0=0,  x1=1,  x2=2;y0=0,  y1=1,  y2=8\Delta x = 1; \quad x_0 = 0, \; x_1 = 1, \; x_2 = 2; \quad y_0 = 0, \; y_1 = 1, \; y_2 = 8

Grid points and function values.

Why this works: Simpson's parameters.
3

Calculate S_2

S2=Δx3[y0+4y1+y2]=13[0+4(1)+8]=123=4S_2 = \frac{\Delta x}{3} [y_0 + 4y_1 + y_2] = \frac{1}{3} [0 + 4(1) + 8] = \frac{12}{3} = 4

S_2 = 4 matches exact value 4 identically.

Why this works: Since f^(4)(x) = 0 for cubics, E_S = 0 exactly.

Answer: S2=∫02x3dx=4S_2 = \int_0^2 x^3 dx = 4

✓ Verified by SymPy CAS

Example 05(Section 8.7, Exercise 5)

Challenge

Problem. Find the maximum error when approximating int_0^1 e^(x^2) dx with Simpson's Rule if M_4 = max |f^(4)(x)| = 76 and n = 10.

Step-by-Step Derivation (3 steps)

1

State Simpson's Error Bound Formula

∣ES∣≤M4(b−a)5180n4|E_S| \le \frac{M_4 (b - a)^5}{180 n^4}

Standard fourth-order error bound.

Why this works: Formula definition.
2

Substitute Given Parameters

M4=76,b−a=1,n=10  ⟹  n4=10000M_4 = 76, \quad b - a = 1, \quad n = 10 \implies n^4 = 10000

Calculate denominator 180 * 10000 = 1,800,000.

Why this works: Arithmetic evaluation.
3

Compute Bound

∣ES∣≤76(1)5180(10000)=761800000=19450000≈4.22×10−5|E_S| \le \frac{76(1)^5}{180(10000)} = \frac{76}{1800000} = \frac{19}{450000} \approx 4.22 \times 10^{-5}

Fraction reduces to 19/450000.

Why this works: Final error bound.

Answer: ∣ES∣≤761800000≈4.22×10−5|E_S| \le \frac{76}{1800000} \approx 4.22 \times 10^{-5}

✓ Verified by SymPy CAS