Fiveable

Calculus II Unit 3 Review

QR code for Calculus II practice questions

3.6 Numerical Integration

3.6 Numerical Integration

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
Calculus II
Unit & Topic Study Guides

Numerical Integration

Numerical integration gives you practical ways to approximate definite integrals when you can't find an antiderivative (or when one doesn't exist in closed form). These methods break the area under a curve into simpler geometric shapes, then sum those areas to estimate the integral. The key questions are always: how close is the approximation? and how can you make it more accurate?

Midpoint and Trapezoidal Rule Applications

The midpoint rule approximates the integral by building rectangles whose heights are determined by the function value at the midpoint of each subinterval. Because it samples the middle rather than the edges, it often performs surprisingly well.

abf(x)dxΔxi=1nf(xi)\int_a^b f(x)\,dx \approx \Delta x \sum_{i=1}^n f(x_i^*)

where Δx=ban\Delta x = \frac{b-a}{n} and xi=xi1+xi2x_i^* = \frac{x_{i-1} + x_i}{2} is the midpoint of the iith subinterval.

The trapezoidal rule connects function values at the endpoints of each subinterval with straight lines, forming trapezoids instead of rectangles. This captures some of the curve's slope that rectangles miss.

abf(x)dxΔx2[f(x0)+2f(x1)+2f(x2)++2f(xn1)+f(xn)]\int_a^b f(x)\,dx \approx \frac{\Delta x}{2}\left[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\right]

where Δx=ban\Delta x = \frac{b-a}{n}.

Notice the pattern in the trapezoidal formula: the first and last function values get a coefficient of 1, while every interior point gets a coefficient of 2. This comes from each interior point being shared by two adjacent trapezoids.

Both methods are Riemann sum approximations. They partition [a,b][a,b] into nn equal subintervals and sum the areas of simpler shapes to estimate the total.

Quick example: To approximate 01exdx\int_0^1 e^x\,dx with n=4n = 4, you'd use Δx=0.25\Delta x = 0.25. For the midpoint rule, evaluate exe^x at x=0.125,0.375,0.625,0.875x = 0.125, 0.375, 0.625, 0.875. For the trapezoidal rule, evaluate at x=0,0.25,0.5,0.75,1x = 0, 0.25, 0.5, 0.75, 1 and apply the weighting pattern above.

Error Calculations in Numerical Integration

Once you have an approximation, you need to measure how good it is.

Absolute error is the straightforward difference between the exact value and your approximation:

Ea=exact valueapproximationE_a = |\text{exact value} - \text{approximation}|

For instance, the exact value of 01x2dx=13\int_0^1 x^2\,dx = \frac{1}{3}. If your trapezoidal approximation with n=4n = 4 gives 0.34375, then Ea=0.3333...0.34375=0.01042E_a = |0.3333... - 0.34375| = 0.01042.

Relative error expresses that absolute error as a proportion of the true value, which is more useful for comparing accuracy across different problems:

Er=exact valueapproximationexact valueE_r = \frac{|\text{exact value} - \text{approximation}|}{|\text{exact value}|}

In the example above, Er=0.010420.33330.03125E_r = \frac{0.01042}{0.3333} \approx 0.03125, or about 3.1%.

Midpoint and trapezoidal rule applications, The Midpoint and Trapezoidal Rules | Calculus II

Error-Bound Formulas

You won't always know the exact value (that's the whole point of numerical integration). Error-bound formulas give you a guaranteed upper limit on the error without needing the exact answer.

  • Midpoint rule error bound:

EMK(ba)324n2|E_M| \leq \frac{K(b-a)^3}{24n^2}

  • Trapezoidal rule error bound:

ETK(ba)312n2|E_T| \leq \frac{K(b-a)^3}{12n^2}

In both formulas, KK is the maximum value of f(x)|f''(x)| on [a,b][a,b].

A few things to notice here:

  • The midpoint bound has 24 in the denominator while the trapezoidal bound has 12. This means the midpoint rule's error bound is actually half that of the trapezoidal rule for the same nn. The midpoint rule is often more accurate than it looks.
  • Both errors shrink proportionally to 1n2\frac{1}{n^2}. Doubling nn cuts the maximum error by a factor of 4.
  • Finding KK requires you to compute f(x)f''(x), then find its maximum absolute value on [a,b][a,b]. You can often use calculus techniques or just evaluate f(x)|f''(x)| at the endpoints and any critical points.

Over- vs. Underestimation

The concavity of ff determines whether each method overshoots or undershoots the true value. This is worth memorizing because it comes up on exams constantly.

ConcavityMidpoint RuleTrapezoidal Rule
Concave up (f(x)>0f''(x) > 0)OverestimatesUnderestimates
Concave down (f(x)<0f''(x) < 0)UnderestimatesOverestimates

Why this happens: When a curve is concave up, it bends upward like a bowl. The midpoint of each subinterval sits above the chord connecting the endpoints, so midpoint rectangles are too tall. Trapezoids, on the other hand, connect the endpoints with straight lines that sit below the curve, so they miss area.

The pattern flips for concave down. If the function changes concavity on the interval, the over- and underestimation effects partially cancel, and you can't make a clean prediction about which direction the error goes.

Midpoint and trapezoidal rule applications, Midpoint method - Wikipedia

Simpson's Rule for Definite Integrals

Simpson's rule takes accuracy a step further by fitting parabolas (not lines or flat tops) through consecutive groups of three points. Because parabolas can match curvature, this method is significantly more precise.

abf(x)dxΔx3[f(x0)+4f(x1)+2f(x2)+4f(x3)++2f(xn2)+4f(xn1)+f(xn)]\int_a^b f(x)\,dx \approx \frac{\Delta x}{3}\left[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 2f(x_{n-2}) + 4f(x_{n-1}) + f(x_n)\right]

where Δx=ban\Delta x = \frac{b-a}{n} and nn must be even.

The coefficient pattern is: 1, 4, 2, 4, 2, ..., 4, 2, 4, 1. The alternating 4s and 2s come from how adjacent parabolic segments share points.

Simpson's rule error bound:

ESK(ba)5180n4|E_S| \leq \frac{K(b-a)^5}{180n^4}

where KK is the maximum value of f(4)(x)|f^{(4)}(x)| on [a,b][a,b]. Note that this uses the fourth derivative, not the second.

The error decreases as 1n4\frac{1}{n^4}, which is dramatically faster than the 1n2\frac{1}{n^2} rate of the midpoint and trapezoidal rules. Doubling nn cuts the error by a factor of 16.

A remarkable consequence: Simpson's rule gives exact results for any polynomial of degree 3 or less, because the fourth derivative of such polynomials is zero, making K=0K = 0.

Finding nn for a specified accuracy:

  1. Compute f(4)(x)f^{(4)}(x) and find its maximum absolute value KK on [a,b][a,b].
  2. Set the error bound less than your desired tolerance: K(ba)5180n4<ϵ\frac{K(b-a)^5}{180n^4} < \epsilon.
  3. Solve for nn: n>(K(ba)5180ϵ)1/4n > \left(\frac{K(b-a)^5}{180\epsilon}\right)^{1/4}.
  4. Round nn up to the next even integer (since Simpson's rule requires even nn).

Advanced Numerical Integration Techniques

  • Composite rules are what you've already been using: applying the midpoint, trapezoidal, or Simpson's rule across many subintervals and summing the results. The formulas above are all composite versions of their respective rules.
  • Gaussian quadrature methods choose evaluation points and weights strategically (not equally spaced) to achieve higher accuracy with fewer function evaluations. These are common in engineering and scientific computing.
  • Adaptive quadrature algorithms automatically use more subintervals where the function changes rapidly and fewer where it's smooth, optimizing the tradeoff between accuracy and computation.