Numerical Integration: Methods, Formulas & Error

#Calculus
TL;DR
Numerical integration approximates the value of a definite integral by sampling the function at a few points instead of finding an antiderivative. You need it when no elementary antiderivative exists, as with $\int_0^1 e^{-x^2},dx$. The three standard rules build the area from simple shapes: the midpoint rule uses rectangles, the trapezoidal rule uses trapezoids, and Simpson's rule uses parabolas. Simpson's rule is by far the most accurate, with error shrinking like $1/n^4$ against $1/n^2$ for the other two.
BT
Bhanzu TeamLast updated on September 29, 202613 min read

What Is Numerical Integration?

Numerical integration is the process of estimating the value of a definite integral $\int_a^b f(x),dx$ from a finite set of function values, without finding a formula for the antiderivative. It replaces the exact area under the curve with the area of shapes we can measure by hand: rectangles, trapezoids, or parabolic caps.

The Fundamental Theorem of Calculus says that if you can find an antiderivative $F$ with $F' = f$, then $\int_a^b f(x),dx = F(b) - F(a)$. That is the exact route, and the methods of integration exist to find those antiderivatives. Numerical integration is the answer to a hard fact: for many perfectly ordinary functions, no antiderivative can be written with the standard toolkit at all.

The classic example is the Gaussian $f(x) = e^{-x^2}$. Its integral runs the entire normal distribution of statistics, yet $\int e^{-x^2},dx$ has no elementary antiderivative. There is no combination of powers, roots, logs, exponentials, and trig functions that differentiates back to $e^{-x^2}$.

So $\int_0^1 e^{-x^2},dx$ cannot be evaluated by the Fundamental Theorem. It can only be approximated, and numerical integration is how.

The general setup is always the same. Split $[a, b]$ into $n$ equal subintervals of width

$$h = \frac{b - a}{n},$$

which creates $n + 1$ evenly spaced points $x_0 = a,\ x_1,\ x_2,\ \dots,\ x_n = b$, where $x_i = a + i,h$. Every rule below is a different recipe for combining the heights $f(x_0), f(x_1), \dots, f(x_n)$ into an estimate of the area.

Why Do We Need Numerical Integration?

Two situations force the numerical route, and both are common.

  • No elementary antiderivative exists. Functions such as $e^{-x^2}$, $\dfrac{\sin x}{x}$, and $\sqrt{1 + x^3}$ are continuous and well behaved, but none has an antiderivative you can write in closed form. The exact-area machinery simply has nothing to grab. For these, the geometric picture of the area under a curve is still perfectly real; only the algebra fails.

  • The function is known only as data. An engineer may have sensor readings of a flow rate every second, not a formula. A definite integral of that data (total volume) still has meaning, and numerical integration computes it straight from the sampled values.

In both cases the goal is a number that is close enough, with a known bound on how far off it can be. That second half matters: a numerical answer is only trustworthy if you can also say how large the error might be.

How Do The Three Numerical Integration Rules Work?

Each rule approximates the curve on every subinterval with a shape whose area is easy, then adds those areas. The pattern goes rectangle, then trapezoid, then parabola, and each step up captures more of the curve's shape.

The midpoint (rectangle) rule. On each subinterval, draw a rectangle whose height is the function value at the midpoint of that strip. This is the well-chosen cousin of the left- and right-endpoint Riemann sums: sampling the middle balances the overshoot on one side against the undershoot on the other. With midpoints $m_i = a + \left(i - \tfrac{1}{2}\right)h$,

$$M_n = h\big[,f(m_1) + f(m_2) + \cdots + f(m_n),\big].$$

Geometrically, you are tiling the region with $n$ rectangles of equal width $h$.

The trapezoidal rule. Instead of a flat rectangle top, join consecutive points $\big(x_{i-1}, f(x_{i-1})\big)$ and $\big(x_i, f(x_i)\big)$ with a straight line, making each strip a trapezoid. Adding the trapezoid areas and collecting terms gives

$$T_n = \frac{h}{2}\big[,f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n),\big].$$

The two endpoints carry weight $1$; every interior point carries weight $2$, because it is shared by two neighbouring trapezoids. The full derivation lives on the trapezoidal rule page.

Simpson's rule. Fit a parabola through each pair of subintervals (three points at a time), and integrate the parabolas exactly. Because a parabola bends, it hugs a curved graph far better than a straight line. With $n$ even,

$$S_n = \frac{h}{3}\big[,f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n),\big].$$

The weights run $1, 4, 2, 4, 2, \dots, 4, 1$: endpoints get $1$, odd-indexed points get $4$, even-indexed interior points get $2$. Requiring $n$ to be even is not a technicality; each parabola needs two subintervals, so the strips must pair up evenly.

How Accurate Is Each Rule? The Error Formulas

Every estimate comes with a guaranteed error bound. Let $M = \max\lvert f''(x)\rvert$ and $L = \max\lvert f^{(4)}(x)\rvert$ on $[a, b]$. Then the worst-case error of each rule is:

Table: Error bounds for the three numerical integration rules on $[a,b]$ with $n$ subintervals.

Rule

Approximation weights

Error bound

Shrinks like

Midpoint $M_n$

$1, 1, \dots, 1$ (midpoints)

$\dfrac{M(b-a)^3}{24,n^2}$

$1/n^2$

Trapezoidal $T_n$

$1, 2, 2, \dots, 2, 1$

$\dfrac{M(b-a)^3}{12,n^2}$

$1/n^2$

Simpson's $S_n$

$1, 4, 2, \dots, 4, 1$

$\dfrac{L(b-a)^5}{180,n^4}$

$1/n^4$

Three facts are worth reading straight off the table.

  • The midpoint and trapezoidal errors both depend on $f''$, the second derivative, which measures curvature. A straight line has $f'' = 0$, so both rules are exact on straight-line graphs. The bigger the curvature, the bigger the error.

  • The midpoint bound is half the trapezoidal bound. The midpoint rule is usually the more accurate of the two, because its rectangles overshoot on one side of a curved strip and undershoot on the other, and the two nearly cancel.

  • Simpson's rule depends on $f^{(4)}$ and shrinks like $1/n^4$. Doubling $n$ cuts a $1/n^2$ error to a quarter, but cuts Simpson's error to a sixteenth. Simpson is also exact for any cubic, which is why it outperforms its parabola-fitting origins.

Can You Compare The Methods On One Integral?

Yes, and one integral shows the whole story. Take

$$\int_0^1 \frac{1}{1 + x^2},dx = \big[\arctan x\big]_0^1 = \frac{\pi}{4} = 0.7853981634,$$

whose exact value we happen to know, so we can measure each rule's error directly. Use $n = 4$, so $h = 0.25$ and the points are $x = 0,\ 0.25,\ 0.5,\ 0.75,\ 1$. The needed heights of $f(x) = \dfrac{1}{1+x^2}$ are

$$f(0) = 1,\quad f(0.25) = 0.9411764706,\quad f(0.5) = 0.8,\quad f(0.75) = 0.64,\quad f(1) = 0.5.$$

Trapezoidal rule. Endpoints weight $1$, interior points weight $2$:

$$T_4 = \frac{0.25}{2}\big[,1 + 2(0.9411764706) + 2(0.8) + 2(0.64) + 0.5,\big] = 0.125 \times 6.2623529412 = 0.7827941176.$$

So $T_4 = 0.7828$, an error of $0.0026$.

Midpoint rule. Sample the four midpoints $0.125, 0.375, 0.625, 0.875$:

$$M_4 = 0.25\big[,0.9846153846 + 0.8767123288 + 0.7191011236 + 0.5663716814,\big] = 0.25 \times 3.1468005184 = 0.7867001296.$$

So $M_4 = 0.7867$, an error of $0.0013$, exactly half the trapezoidal error and on the opposite side of the true value.

Simpson's rule. Weights $1, 4, 2, 4, 1$:

$$S_4 = \frac{0.25}{3}\big[,1 + 4(0.9411764706) + 2(0.8) + 4(0.64) + 0.5,\big] = \frac{9.4247058824}{12} = 0.7853921569.$$

So $S_4 = 0.7854$, an error of just $0.0000060$. With the same five function values, Simpson lands more than four hundred times closer than the trapezoidal rule.

Final answer: for $\int_0^1 \frac{1}{1+x^2},dx = 0.7853981634$, the four-strip estimates are $M_4 = 0.7867$, $T_4 = 0.7828$, and $S_4 = 0.7854$.

Table: The three rules against the exact value of $\int_0^1 \frac{1}{1+x^2},dx = 0.7853981634$, with $n = 4$.

Rule

Estimate

Absolute error

Trapezoidal $T_4$

$0.7828$

$0.0026$

Midpoint $M_4$

$0.7867$

$0.0013$

Simpson's $S_4$

$0.7854$

$0.0000060$

Notice that $M_4$ overshoots and $T_4$ undershoots by about twice as much. That is not a coincidence: on a curve of one concavity the trapezoidal error is roughly $-2$ times the midpoint error, and Simpson's rule is exactly the weighted blend $S = \tfrac{1}{3}(T + 2M)$ that cancels them.

How Do You Handle An Integral With No Antiderivative?

Return to the motivating case, the non-elementary $\int_0^1 e^{-x^2},dx$. Here the Fundamental Theorem is powerless because no elementary $F$ exists, so a numerical estimate is the only honest answer.

Use Simpson's rule with $n = 4$, $h = 0.25$, on $f(x) = e^{-x^2}$:

$$f(0) = 1,\ \ f(0.25) = 0.9394130628,\ \ f(0.5) = 0.7788007831,\ \ f(0.75) = 0.5697828,\ \ f(1) = 0.3678794412.$$

$$S_4 = \frac{0.25}{3}\big[,1 + 4(0.9394130628) + 2(0.7788007831) + 4(0.5697828) + 0.3678794412,\big] = \frac{8.9622644586}{12} = 0.7468553715.$$

Final answer: $\int_0^1 e^{-x^2},dx \approx 0.7469$. The true value, defined through the error function, is $0.7468241$, so even four strips are accurate to four decimal places. There is no exact closed form to quote here, and inventing one would be wrong; the number $0.7469$ is the result, delivered with Simpson's rule.

Why Does Numerical Integration Work?

The whole method rests on one idea from the definition of the integral: the area under a curve is a limit of sums of thin strips, so any good strip shape gives a good estimate.

  • A definite integral already is a sum. The integral is defined as the limit of Riemann sums as the strips get infinitely thin. Numerical integration just stops at a finite number of strips, so it is the same idea halted early, with an error you can bound rather than send to zero.

  • Better shapes track the curve's bending. Rectangles ignore the slope, trapezoids capture the slope, and parabolas capture the curvature. Each added feature removes a layer of error, which is exactly why the error bounds move from depending on $f''$ (midpoint, trapezoidal) to depending on $f^{(4)}$ (Simpson).

  • Smoothness controls the error. The bounds contain a derivative of $f$ because a wildly bending function is harder to approximate with simple caps. If the higher derivatives are small, the estimate is superb; the same reasoning connects Simpson's parabolas to the polynomial fits behind a Taylor series.

Read together, numerical integration is not a workaround bolted onto calculus. It is the original definition of the integral, used forwards: build the area from pieces, and choose pieces that fit.

Who Invented Simpson's Rule And The Numerical Integration Formulas?

The most famous rule carries the wrong name, which makes its history a small lesson in how mathematics gets credited.

The broader family has clearer parentage. The Newton–Cotes formulas, the general scheme of fitting a polynomial through equally spaced points and integrating it, were developed by Isaac Newton and Roger Cotes (1682–1716, England) in the early 1700s. The midpoint, trapezoidal, and Simpson's rules are simply the first three members of that family, using polynomials of degree zero, one, and two.

Where Is Numerical Integration Used In The Real World?

Whenever a quantity is an integral but the integrand is data or non-elementary, numerical integration does the work.

  • Statistics and probability: the area under the normal bell curve gives every probability in a $z$-table, and because $e^{-x^2/2}$ has no elementary antiderivative, those tables were built by numerical integration.

  • Medicine and pharmacology: the total drug exposure in a patient, the "area under the curve" of concentration against time, is computed by the trapezoidal rule directly from blood-sample readings.

  • Engineering: the volume of an irregular tank, the work done by a variable force, or the total flow through a pipe is found by integrating sampled sensor values that never came with a formula.

  • Economics: consumer and producer surplus are integrals of demand and supply curves that are often known only as discrete price–quantity points.

  • Computer graphics and physics engines: rendering, lighting, and motion simulation evaluate integrals thousands of times per frame using fast numerical rules.

One toolkit of rectangles, trapezoids, and parabolas quietly powers medicine, finance, engineering, and every image on a screen, which is why numerical integration is a core skill rather than a curiosity.

What Are The Most Common Mistakes With Numerical Integration?

These four errors account for most lost marks, and each matches a documented student error or a Google "People also ask" question on the topic.

Using an odd number of subintervals with Simpson's rule.

Where it slips in:

A student sets up Simpson's rule with $n = 5$ strips because the problem gave five intervals, then applies the $1, 4, 2, 4, 1$ pattern and it runs out of step.

Don't do this:

Do not use Simpson's rule when $n$ is odd. Each parabola spans two subintervals, so an odd count leaves one strip with no partner.

The correct way:

Choose an even $n$ (for example $4$, $6$, or $8$). If the data forces an odd number of strips, handle the leftover strip separately with the trapezoidal rule.

Miscounting points and the strip width $h$.

Where it slips in:

A student splits $[a, b]$ into $n$ subintervals but then uses $n$ points, or sets $h = \dfrac{b-a}{n+1}$, shifting every node.

Don't do this:

Do not confuse strips with points. $n$ subintervals produce $n + 1$ points, and the width is $h = \dfrac{b-a}{n}$.

The correct way:

List the points first: $x_i = a + i,h$ for $i = 0, 1, \dots, n$, then check that $x_0 = a$ and $x_n = b$ before summing.

Applying the wrong weight pattern.

Where it slips in:

In Simpson's rule a student gives every interior point a weight of $4$, or gives the endpoints weight $2$ as in the trapezoidal rule.

Don't do this:

Do not blur the patterns. Trapezoidal weights are $1, 2, 2, \dots, 2, 1$; Simpson's weights are $1, 4, 2, 4, \dots, 4, 1$, alternating $4$ and $2$ on the interior with $4$ on the odd-indexed points.

The correct way:

Write the weights above the function values before adding, and confirm the two ends are $1$ and the interior alternates correctly.

Assuming the trapezoidal rule always overestimates.

Where it slips in:

A student remembers "trapezoids overestimate" and subtracts a correction, or trusts a raw estimate without checking how large the error could be.

Don't do this:

Do not treat the direction of the error as fixed. The trapezoidal rule overestimates only where $f$ is concave up ($f'' > 0$) and underestimates where $f$ is concave down.

The correct way:

Judge the direction from the concavity, and quote the error bound $\dfrac{M(b-a)^3}{12,n^2}$ to say how large the error can be, rather than guessing.

Practice Problems On Numerical Integration

Work each one, then check the verified answer.

  1. Estimate $\int_0^2 x^2,dx$ with the trapezoidal rule and $n = 4$.
    (Answer: $h = 0.5$, heights $0, 0.25, 1, 2.25, 4$, so $T_4 = 0.25[,0 + 0.5 + 2 + 4.5 + 4,] = 2.75$. Exact value $\tfrac{8}{3} \approx 2.6667$.)

  2. Estimate the same $\int_0^2 x^2,dx$ with the midpoint rule and $n = 4$.
    (Answer: midpoints $0.25, 0.75, 1.25, 1.75$, heights sum $5.25$, so $M_4 = 0.5 \times 5.25 = 2.625$.)

  3. Estimate $\int_0^2 x^2,dx$ with Simpson's rule and $n = 4$.
    (Answer: $S_4 = \tfrac{0.5}{3}[,0 + 4(0.25) + 2(1) + 4(2.25) + 4,] = \tfrac{0.5}{3}\times 16 = 2.6667$, exactly $\tfrac{8}{3}$, since Simpson is exact for quadratics.)

  4. Estimate $\int_0^1 x^3,dx$ with Simpson's rule and $n = 2$.
    (Answer: $h = 0.5$, $S_2 = \tfrac{0.5}{3}[,0 + 4(0.125) + 1,] = 0.25$, the exact value, since Simpson is exact for cubics too.)

  5. Estimate $\int_1^2 \dfrac{1}{x},dx$ with the trapezoidal rule and $n = 2$.
    (Answer: $h = 0.5$, $T_2 = 0.25[,1 + 2(0.6667) + 0.5,] = 0.7083$. Exact value $\ln 2 \approx 0.6931$.)

  6. Explain in one line why $n$ must be even for Simpson's rule.
    (Answer: each parabola is fitted across two subintervals, so the strips must pair up, which needs an even count.)

Where Should You Go Next After Numerical Integration?

Numerical integration sits at the crossroads of areas, sums, and approximation, and several natural doors open from here.

  1. Trapezoidal rule. Go deeper on the straight-line rule, its full derivation, and its error term.

  2. Riemann sums. Revisit the definition of the integral as a limit of strips, the idea every rule here is built on.

  3. Definite integrals. Strengthen the exact side, so you know when to compute and when to approximate.

If your child is building calculus foundations and wants the geometry behind every rule, a live Bhanzu trainer teaches numerical integration from the strip picture up in the Bhanzu math program.

Book a Free Demo

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is numerical integration in simple terms?
Numerical integration estimates a definite integral by sampling the function at a few points and adding up the areas of simple shapes (rectangles, trapezoids, or parabolas). It is used when an antiderivative cannot be found or when the function is known only as data.
When do you need numerical integration instead of the exact method?
You need it whenever the integrand has no elementary antiderivative, such as $e^{-x^2}$ or $\tfrac{\sin x}{x}$, or whenever the function is given as measured data rather than a formula. In those cases the Fundamental Theorem cannot be applied and an approximation is the only route.
Which numerical integration rule is the most accurate?
Simpson's rule, in almost every case. Its error shrinks like $1/n^4$ and it is exact for any cubic, while the midpoint and trapezoidal rules have errors that shrink only like $1/n^2$. Doubling the number of strips cuts Simpson's error to a sixteenth.
Why must $n$ be even in Simpson's rule?
Because Simpson's rule fits one parabola across every pair of subintervals. Two subintervals make one parabola, so the strips have to pair up exactly, which is only possible when the number of subintervals is even.
Is the trapezoidal rule always an overestimate?
No. The trapezoidal rule overestimates only where the graph is concave up and underestimates where it is concave down. Its error depends on the second derivative, so the direction of the error follows the curve's concavity.
How is numerical integration related to Riemann sums?
A definite integral is defined as the limit of Riemann sums as the strips become infinitely thin. Numerical integration stops at a finite number of strips and chooses a smart shape for each, so it is a Riemann sum halted early with a controllable error.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →