Skip to content

Simpson's Rule

Simpson’s Rule is the closed Newton-Cotes formula for n=2n = 2. Instead of fitting a straight line through two points, it fits a parabola through three equally spaced nodes: the left endpoint, the midpoint, and the right endpoint. Integrating this parabola exactly gives a considerably more accurate result than the Trapezoidal Rule for the same function.

f(x) in blue with a dashed orange parabola P_2(x) fitted through three equally spaced nodes x_0=a, x_1=(a+b)/2, and x_2=b; the area under the parabola is shaded orange with each node weight labeled.

The parabola matches f(x)f(x) exactly at all three nodes; integrating it exactly yields the 1-4-1 weight pattern visible in the σk\sigma_k labels above.


Setup

For n=2n = 2 the three nodes and their function values are:

Nodexx valueff value
x0x_0aaf(a)f(a)
x1x_1a+b2\dfrac{a+b}{2}f ⁣(a+b2)f\!\left(\dfrac{a+b}{2}\right)
x2x_2bbf(b)f(b)

The Newton-Cotes formula gives:

I2=σ0 f(x0)+σ1 f(x1)+σ2 f(x2)I_2 = \sigma_0\, f(x_0) + \sigma_1\, f(x_1) + \sigma_2\, f(x_2)

We compute each weight σk=∫ablk(x) dx\sigma_k = \int_a^b l_k(x)\,dx in turn.


Derivation of σ0\sigma_0

σ0=∫abl0(x) dx=∫ab(x−x1)(x−x2)(x0−x1)(x0−x2) dx\sigma_0 = \int_a^b l_0(x)\,dx = \int_a^b \frac{(x - x_1)(x - x_2)}{(x_0 - x_1)(x_0 - x_2)}\,dx

Substituting the node values:

=∫ab(x−a+b2)(x−b)(a−a+b2)(a−b) dx= \int_a^b \frac{\left(x - \tfrac{a+b}{2}\right)(x - b)}{\left(a - \tfrac{a+b}{2}\right)(a - b)}\,dx

The denominator factors simplify: a−a+b2=a−b2a - \tfrac{a+b}{2} = \tfrac{a-b}{2}, so (a−a+b2)(a−b)=(a−b)22(a - \tfrac{a+b}{2})(a-b) = \tfrac{(a-b)^2}{2}. Rewriting the numerator factor x−a+b2=2x−a−b2x - \tfrac{a+b}{2} = \tfrac{2x-a-b}{2}:

=∫ab(2x−a−b)2(x−b)(a−b)22 dx=1(a−b)2∫ab(2x−a−b)(x−b) dx= \int_a^b \frac{\tfrac{(2x-a-b)}{2}(x-b)}{\tfrac{(a-b)^2}{2}}\,dx = \frac{1}{(a-b)^2}\int_a^b (2x-a-b)(x-b)\,dx

Expanding the integrand:

=1(a−b)2∫ab(2x2−ax−bx−2bx+ab+b2)dx= \frac{1}{(a-b)^2}\int_a^b \left(2x^2 - ax - bx - 2bx + ab + b^2\right)dx

Integrating term by term:

=1(a−b)2[2x33−ax22−bx22−bx2+abx+b2x]ab= \frac{1}{(a-b)^2}\left[\frac{2x^3}{3} - \frac{ax^2}{2} - \frac{bx^2}{2} - bx^2 + abx + b^2 x\right]_a^b

Evaluating at both limits and writing the combined expression:

=1(a−b)2(2b33−ab22−b32−b3+ab2+b3−2a33+a32+a2b2+a2b−a2b−ab2)= \frac{1}{(a-b)^2}\left(\frac{2b^3}{3} - \frac{ab^2}{2} - \frac{b^3}{2} - b^3 + ab^2 + b^3 - \frac{2a^3}{3} + \frac{a^3}{2} + \frac{a^2b}{2} + a^2b - a^2b - ab^2\right)

Collecting like terms:

=1(a−b)2(2b33−2a33+a32−b32+a2b2−ab22)= \frac{1}{(a-b)^2}\left(\frac{2b^3}{3} - \frac{2a^3}{3} + \frac{a^3}{2} - \frac{b^3}{2} + \frac{a^2b}{2} - \frac{ab^2}{2}\right)

Converting to a common denominator of 144:

=1(a−b)2⋅96b3−96a3+72a3−72b3+72a2b−72ab2144= \frac{1}{(a-b)^2} \cdot \frac{96b^3 - 96a^3 + 72a^3 - 72b^3 + 72a^2b - 72ab^2}{144}

=1(a−b)2⋅24b3−24a3+72a2b−72ab2144= \frac{1}{(a-b)^2} \cdot \frac{24b^3 - 24a^3 + 72a^2 b - 72ab^2}{144}

=1(a−b)2⋅24(b3−a3+3a2b−3ab2)144= \frac{1}{(a-b)^2} \cdot \frac{24\bigl(b^3 - a^3 + 3a^2 b - 3ab^2\bigr)}{144}

Recognizing that b3−a3+3a2b−3ab2=(b−a)3b^3 - a^3 + 3a^2b - 3ab^2 = (b-a)^3:

σ0=1(b−a)2⋅(b−a)36=b−a6\sigma_0 = \frac{1}{(b-a)^2} \cdot \frac{(b-a)^3}{6} = \frac{b-a}{6}


Derivation of σ1\sigma_1

σ1=∫abl1(x) dx=∫ab(x−x0)(x−x2)(x1−x0)(x1−x2) dx\sigma_1 = \int_a^b l_1(x)\,dx = \int_a^b \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1 - x_2)}\,dx

The denominator factors are x1−x0=b−a2x_1 - x_0 = \tfrac{b-a}{2} and x1−x2=a−b2x_1 - x_2 = \tfrac{a-b}{2}, so their product is −(b−a)24-\tfrac{(b-a)^2}{4}. Therefore:

σ1=−4(b−a)2∫ab(x−a)(x−b) dx\sigma_1 = \frac{-4}{(b-a)^2}\int_a^b (x-a)(x-b)\,dx

Expanding the integrand:

=−4(b−a)2∫ab(x2−ax−bx+ab)dx= \frac{-4}{(b-a)^2}\int_a^b \left(x^2 - ax - bx + ab\right)dx

Integrating term by term:

=−4(b−a)2[x33−ax22−bx22+abx]ab= \frac{-4}{(b-a)^2}\left[\frac{x^3}{3} - \frac{ax^2}{2} - \frac{bx^2}{2} + abx\right]_a^b

Evaluating at both limits and writing the combined expression:

=−4(b−a)2(b33−ab22−b32+ab2−a33+a32+a2b2−a2b)= \frac{-4}{(b-a)^2}\left(\frac{b^3}{3} - \frac{ab^2}{2} - \frac{b^3}{2} + ab^2 - \frac{a^3}{3} + \frac{a^3}{2} + \frac{a^2b}{2} - a^2b\right)

Converting to a common denominator of 144:

=−4(b−a)2⋅48b3−72ab2−72b3+144ab2−48a3+72a3+72a2b−144a2b144= \frac{-4}{(b-a)^2} \cdot \frac{48b^3 - 72ab^2 - 72b^3 + 144ab^2 - 48a^3 + 72a^3 + 72a^2b - 144a^2b}{144}

=−4(b−a)2⋅−24b3+24a3+72ab2−72a2b144= \frac{-4}{(b-a)^2} \cdot \frac{-24b^3 + 24a^3 + 72ab^2 - 72a^2b}{144}

=−4(b−a)2⋅24(a3−b3−3a2b+3ab2)144= \frac{-4}{(b-a)^2} \cdot \frac{24\bigl(a^3 - b^3 - 3a^2 b + 3ab^2\bigr)}{144}

Recognizing that a3−b3−3a2b+3ab2=(a−b)3=−(b−a)3a^3 - b^3 - 3a^2b + 3ab^2 = (a-b)^3 = -(b-a)^3:

σ1=−4(b−a)2⋅−(b−a)36=4(b−a)6=2(b−a)3\sigma_1 = \frac{-4}{(b-a)^2} \cdot \frac{-(b-a)^3}{6} = \frac{4(b-a)}{6} = \frac{2(b-a)}{3}


Derivation of σ2\sigma_2

σ2=∫abl2(x) dx=∫ab(x−x0)(x−x1)(x2−x0)(x2−x1) dx\sigma_2 = \int_a^b l_2(x)\,dx = \int_a^b \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)}\,dx

The denominator factors are x2−x0=b−ax_2 - x_0 = b - a and x2−x1=b−a2x_2 - x_1 = \tfrac{b-a}{2}, giving a product of (b−a)22\tfrac{(b-a)^2}{2}. Rewriting x−x1=2x−a−b2x - x_1 = \tfrac{2x-a-b}{2}:

σ2=1(b−a)2∫ab(x−a)(2x−a−b) dx\sigma_2 = \frac{1}{(b-a)^2}\int_a^b (x-a)(2x-a-b)\,dx

Expanding the integrand:

=1(b−a)2∫ab(2x2−ax−bx−2ax+a2+ab)dx= \frac{1}{(b-a)^2}\int_a^b \left(2x^2 - ax - bx - 2ax + a^2 + ab\right)dx

Integrating term by term:

=1(b−a)2[2x33−ax22−bx22−ax2+a2x+abx]ab= \frac{1}{(b-a)^2}\left[\frac{2x^3}{3} - \frac{ax^2}{2} - \frac{bx^2}{2} - ax^2 + a^2 x + abx\right]_a^b

Evaluating at both limits and writing the combined expression:

=1(b−a)2(2b33−ab22−b32−ab2+a2b+ab2−2a33+a32+a2b2+a3−a3−a2b)= \frac{1}{(b-a)^2}\left(\frac{2b^3}{3} - \frac{ab^2}{2} - \frac{b^3}{2} - ab^2 + a^2b + ab^2 - \frac{2a^3}{3} + \frac{a^3}{2} + \frac{a^2b}{2} + a^3 - a^3 - a^2b\right)

Collecting like terms:

=1(b−a)2(2b33−2a33+a32−b32−ab22+a2b2)= \frac{1}{(b-a)^2}\left(\frac{2b^3}{3} - \frac{2a^3}{3} + \frac{a^3}{2} - \frac{b^3}{2} - \frac{ab^2}{2} + \frac{a^2b}{2}\right)

Converting to a common denominator of 144:

=1(b−a)2⋅96b3−96a3+72a3−72b3−72ab2+72a2b144= \frac{1}{(b-a)^2} \cdot \frac{96b^3 - 96a^3 + 72a^3 - 72b^3 - 72ab^2 + 72a^2b}{144}

=1(b−a)2⋅24b3−24a3−72ab2+72a2b144= \frac{1}{(b-a)^2} \cdot \frac{24b^3 - 24a^3 - 72ab^2 + 72a^2b}{144}

=1(b−a)2⋅24(b3−a3−3ab2+3a2b)144= \frac{1}{(b-a)^2} \cdot \frac{24\bigl(b^3 - a^3 - 3ab^2 + 3a^2b\bigr)}{144}

Recognizing that b3−a3−3ab2+3a2b=(b−a)3b^3 - a^3 - 3ab^2 + 3a^2b = (b-a)^3:

σ2=1(b−a)2⋅(b−a)36=b−a6\sigma_2 = \frac{1}{(b-a)^2} \cdot \frac{(b-a)^3}{6} = \frac{b-a}{6}


Simpson’s Rule: Final Formula

The three weights are:

σ0=b−a6,σ1=2(b−a)3,σ2=b−a6\sigma_0 = \frac{b-a}{6}, \qquad \sigma_1 = \frac{2(b-a)}{3}, \qquad \sigma_2 = \frac{b-a}{6}

Substituting into I2=σ0f(x0)+σ1f(x1)+σ2f(x2)I_2 = \sigma_0 f(x_0) + \sigma_1 f(x_1) + \sigma_2 f(x_2):

I2=b−a6[f(a)+4f ⁣(a+b2)+f(b)]\boxed{I_2 = \frac{b-a}{6}\left[f(a) + 4f\!\left(\frac{a+b}{2}\right) + f(b)\right]}


Why Simpson’s Rule is More Accurate

Even though the Trapezoidal Rule and Simpson’s Rule both use the same interval [a,b][a, b], Simpson’s Rule is significantly more accurate for smooth functions. The reason is the degree of the underlying interpolant: a line (degree 1) versus a parabola (degree 2). Because the error in polynomial interpolation grows with the degree mismatch between the true function and the polynomial, a higher-degree interpolant can track the curvature of f(x)f(x) and leave much less residual. In fact, Simpson’s Rule integrates all polynomials of degree up to 3 exactly, not just up to degree 2, a bonus that arises from the symmetry of the node placement.