6. Numerical Differentiation and Integration I

Simpson’s Rule

Simpson’s Rule

students, in this lesson you will learn one of the most useful techniques in numerical integration: Simpson’s rule 📘✨. In many real-world problems, the exact integral of a function is hard or impossible to find by hand, especially when the function comes from data, measurements, or a complicated formula. Simpson’s rule gives a powerful way to estimate the area under a curve using parabolas instead of straight lines.

What Simpson’s Rule Is and Why It Matters

The goal of numerical integration is to approximate a definite integral like $\int_a^b f(x)\,dx$ when exact integration is difficult. In Numerical Analysis, this is important because engineers, scientists, and computer programs often need answers fast and with known accuracy. For example, a weather model may need to estimate rainfall over time, or a physics program may need to estimate distance from a velocity graph.

Simpson’s rule is based on the idea that a curve can be approximated better by a smooth quadratic polynomial than by a line segment. A quadratic polynomial has the shape of a parabola. Instead of connecting points with straight lines, Simpson’s rule fits a parabola through selected points of the function and uses the area under that parabola as the approximation. This usually gives a more accurate result than the trapezoidal rule for smooth functions 🌟.

The most common form is the composite Simpson’s rule, which uses an even number of subintervals. If $[a,b]$ is divided into $n$ equal parts, where $n$ is even, then the step size is $h=\frac{b-a}{n}$. The points are $x_i=a+ih$ for $i=0,1,2,\dots,n$. The approximation is

$$\int_a^b f(x)\,dx \approx \frac{h}{3}\left[f(x_0)+f(x_n)+4\sum_{\text{odd }i} f(x_i)+2\sum_{\text{even }i,\,0<i<n} f(x_i)\right].$$

This formula is one of the core tools in Numerical Differentiation and Integration I because it shows how function values at sampled points can replace exact calculus when exact calculus is not practical.

The Main Idea Behind the Formula

To understand Simpson’s rule, students, imagine trying to estimate the area under a smooth curve between two points. If you use rectangles, the shape may not match the curve well. If you use trapezoids, the fit improves because the top edge is slanted instead of flat. Simpson’s rule improves again by using a parabola over each pair of subintervals.

Here is the key idea: Simpson’s rule works on pairs of subintervals at a time. That is why the number of subintervals must be even. For one pair, the interval from $x_0$ to $x_2$ is split at the midpoint $x_1$. The area estimate becomes

$$\int_{x_0}^{x_2} f(x)\,dx \approx \frac{h}{3}\left[f(x_0)+4f(x_1)+f(x_2)\right].$$

Notice the weights $1,4,1. The middle point gets the largest weight because the parabola is strongly influenced by the midpoint value. When many pairs are combined, the interior points alternate weights of $4$ and $2$, depending on whether they are odd or even indexed points.

This weighting is not random. It comes from integrating the quadratic interpolating polynomial through three points. In other words, Simpson’s rule is built from polynomial approximation, which is a big theme in Numerical Analysis. It uses known values of $f(x)$ to create a simpler model of the curve, then integrates that model exactly.

How to Apply Simpson’s Rule Step by Step

Let’s work through the procedure carefully. Suppose you want to estimate $\int_a^b f(x)\,dx$.

  1. Choose an even number $n$ of subintervals.
  2. Compute the step size $h=\frac{b-a}{n}$.
  3. Find the points $x_0,x_1,\dots,x_n$ where $x_i=a+ih$.
  4. Evaluate the function at each point: $f(x_0),f(x_1),\dots,f(x_n)$.
  5. Plug the values into Simpson’s formula.

Let’s use a simple example. Estimate

$$\int_0^2 x^2\,dx$$

using Simpson’s rule with $n=2$.

First, $h=\frac{2-0}{2}=1$. The points are $x_0=0$, $x_1=1$, and $x_2=2$. The function values are $f(0)=0$, $f(1)=1$, and $f(2)=4$. Apply the formula:

$$\int_0^2 x^2\,dx \approx \frac{1}{3}[0+4(1)+4]=\frac{8}{3}.$$

The exact integral is

$$\int_0^2 x^2\,dx=\frac{x^3}{3}\Big|_0^2=\frac{8}{3}.$$

So Simpson’s rule gives the exact answer here. This is not an accident. Simpson’s rule is exact for all polynomials of degree at most $3$, such as $1$, $x$, $x^2$, and $x^3$. That is one reason it is so effective for smooth functions ✅.

Why Simpson’s Rule Is Often More Accurate Than the Trapezoidal Rule

The trapezoidal rule approximates the curve with straight line segments. That can work well, but it is less precise when the curve bends strongly. Simpson’s rule captures curvature by using a parabola, so it typically reduces error for smooth functions.

For example, suppose a car’s velocity changes smoothly over time. If you want distance traveled, you need the area under the velocity curve. A trapezoid might underestimate or overestimate if the graph curves. Simpson’s rule can model the bend more accurately because parabolas are flexible enough to follow smooth curvature better than lines.

A useful comparison is this: if the function is very smooth, Simpson’s rule often achieves much better accuracy with the same number of sample points. However, if the data is noisy or rough, the extra curvature fit may not help as much. In real measurements, the quality of the data matters as much as the formula itself.

The reason for the improved accuracy comes from error behavior. For sufficiently smooth functions, the composite Simpson’s rule has an error that decreases rapidly as $h$ gets smaller. In fact, its error is typically proportional to $h^4$ for smooth enough functions, which is much better than the trapezoidal rule’s usual $h^2$ behavior. That means halving the step size can dramatically improve the result 📈.

A Real-World Example with Data

Imagine students is analyzing temperature readings from a sensor over a day. Suppose the sensor measures temperature at evenly spaced times, and you want to estimate the total accumulated temperature exposure over a period. The definite integral of temperature with respect to time gives a kind of accumulated effect.

If the data points are evenly spaced and there are an even number of subintervals, Simpson’s rule is a natural choice. Say the times are $t_0,t_1,t_2,t_3,t_4$ with spacing $h$, and the temperatures are $T_0,T_1,T_2,T_3,T_4$. Then the estimate of the integral from $t_0$ to $t_4$ is

$$\int_{t_0}^{t_4} T(t)\,dt \approx \frac{h}{3}\left[T_0+T_4+4(T_1+T_3)+2T_2\right].$$

This formula shows how Simpson’s rule uses the pattern $1,4,2,4,1 for five points. The method is especially helpful when the data points come from experiments and no exact formula for $T(t)$ is available.

A practical point is that Simpson’s rule requires evenly spaced points. If the data are not evenly spaced, the standard formula does not apply directly. In that case, a different numerical method or interpolation approach may be needed.

Connection to Numerical Differentiation and Integration I

Simpson’s rule belongs to the broader family of numerical integration methods, which also includes the trapezoidal rule and rectangular rules. Together, these methods form the foundation of Numerical Differentiation and Integration I. In the same course area, students also study finite differences, which approximate derivatives from nearby function values.

That connection is important because both differentiation and integration in numerical analysis rely on sampled data. For differentiation, we estimate slopes from points. For integration, we estimate areas from points. In both cases, the main challenge is to replace an exact mathematical operation with a stable, accurate approximation.

Simpson’s rule also connects to interpolation. The method comes from quadratic interpolation, where a polynomial is built through data points. This is a central idea in numerical methods: use a simpler, well-understood function to model the original one. By doing that, students can turn a difficult integral into a formula based on values that are easy to compute or measure.

Important Conditions and Common Mistakes

There are a few things to remember when using Simpson’s rule:

  • The number of subintervals $n$ must be even.
  • The points must be equally spaced, with $h=\frac{b-a}{n}$.
  • The function should be reasonably smooth for the method to be highly accurate.
  • The formula uses alternating weights, so careful arithmetic matters.

A common mistake is forgetting the factor $\frac{h}{3}$. Another mistake is using Simpson’s rule with an odd number of subintervals. If $n$ is odd, the standard composite Simpson’s rule cannot cover the whole interval by pairs of subintervals. Students sometimes try to force the formula anyway, but that breaks the method.

Another helpful check is to remember the weight pattern. For $n=4$, the coefficients are

$$1,4,2,4,1.$$

For $n=6$, they are

$$1,4,2,4,2,4,1.$$

This pattern makes it easier to apply the rule correctly.

Conclusion

Simpson’s rule is a major numerical integration method that estimates integrals by fitting parabolas through function values. It is more accurate than the trapezoidal rule for many smooth functions because it captures curvature better. It fits directly into Numerical Differentiation and Integration I by showing how calculus ideas can be turned into practical formulas for data and computation. students, if you understand the ideas of step size, equal spacing, even subintervals, and weighted sums, you have learned a key tool used across science, engineering, and computation 🚀.

Study Notes

  • Simpson’s rule estimates $\int_a^b f(x)\,dx$ using quadratic interpolation.
  • The composite Simpson’s rule requires an even number of subintervals $n$.
  • The step size is $h=\frac{b-a}{n}$, with points $x_i=a+ih$.
  • The formula is

$$\int_a^b f(x)\,dx \approx \frac{h}{3}\left[f(x_0)+f(x_n)+4\sum_{\text{odd }i} f(x_i)+2\sum_{\text{even }i,\,0<i<n} f(x_i)\right].$$

  • For one pair of subintervals, the formula is

$$\int_{x_0}^{x_2} f(x)\,dx \approx \frac{h}{3}\left[f(x_0)+4f(x_1)+f(x_2)\right].$$

  • Simpson’s rule is exact for polynomials up to degree $3$.
  • It is usually more accurate than the trapezoidal rule for smooth functions.
  • It requires equally spaced data points.
  • It is part of the broader Numerical Differentiation and Integration I topic, alongside finite differences and other integration rules.
  • Real-world uses include estimating distance, accumulated quantity, and total effect from sampled data.

Practice Quiz

5 questions to test your understanding