Evaluating an integral using Simpson’s Rule

calculusdefinite integralsintegrationnumerical methodssimpsons rule

Below is a problem I made up and did. I would be interested in feed back from the group on the quality of my answer. Does breaking up the integral in two parts make sense?

Problem:

Give an estimate of the following integral using Simpson's Rule to within 1%.
$$ \int_0^5 x^8 \,\, dx $$
Answer:

Observe that the function is growing rapidly when $x$ is large. So, my plan is to break the integral in
two parts and evaluate each integral separately.
$$ \int_0^5 x^8 \,\, dx = \int_0^4 x^8 \,\, dx + \int_4^5 x^8 \,\, dx $$
Let $S_1$ and $S_2$ be the estimates for the two integrals respectively. Let $S$ be the Simpson's rule estimate
for the original integral. We have $S = S_1 + S_2$. The first step is to compute $S_1$. We have:
\begin{align*}
a &= 0 \\
b &= 4 \\
n &= 8 \\
h &= \frac{b-a}{n} = \frac{4-0}{8} = \frac{1}{2} \\
S_1 &= \left( \frac{h}{3} \right) \left( f(0) + 4f\left( \frac{1}{2} \right) + 2f(1) + 4f \left( \frac{3}{2} \right)
+ 2f( 2 ) + 4f\left( \frac{5}{2} \right)
+ 2f( 3 ) + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
f(0) &= 0 \\
f\left( \frac{1}{2 }\right) &= \frac{1}{256} \\
f(1) &= 1 \\
S_1 &= \left( \frac{1}{6} \right) \left( 4 + 4\left( \frac{1}{256} \right) + 2(1) + 4f \left( \frac{3}{2} \right)
+ 2f( 2 ) + 4f\left( \frac{5}{2} \right)
+ 2f( 3 ) + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
S_1 &= \left( \frac{1}{6} \right) \left( 6 + \frac{1}{64} + 4f \left( \frac{3}{2} \right)
+ 2f( 2 ) + 4f\left( \frac{5}{2} \right)
+ 2f( 3 ) + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
f\left( \frac{3}{2 }\right) &= \frac{6165}{256} \\
f(2) &= 256 \\
%
S_1 &= \left( \frac{1}{6} \right) \left( 6 + \frac{1}{64} + 4 \left( \frac{6165}{256} \right)
+ 2(256) + 4f\left( \frac{5}{2} \right)
+ 2f( 3 ) + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
%
f\left( \frac{5}{2} \right) &= \frac{ 5^8 } { 256 } \\
f(3) &= 3^8 = 6561 \\
S_1 &= \left( \frac{1}{6} \right) \left( 6 + \frac{1}{64} + \left( \frac{6165}{64} \right)
+ 512 + 4\left( \frac{ 5^8 } { 256 } \right)
+ 2( 6561 ) + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
S_1 &= \left( \frac{1}{6} \right) \left( 518 + \frac{1}{64} + \left( \frac{6165}{64} \right)
+ \left( \frac{ 5^8 } { 64 } \right)
+ 13122 + 4f\left( \frac{7}{2} \right) + f(4) \right) \\
f\left( \frac{7}{2} \right) &= \frac{7^8 } {256 } \\
f(4) &= 4^8 = 65536 \\
S_1 &= \left( \frac{1}{6} \right) \left( 518 + \frac{1}{64} + \left( \frac{6165}{64} \right)
+ \left( \frac{ 5^8 } { 64 } \right)
+ 13122 + 4\left( \frac{7^8 } {256 } \right) + 65536 \right) \\
\end{align*}

Now finding $S_1$ is arithmetic. We will be switching to decimal numbers, hence our answer will only be an estimate.
\begin{align*}
S_1 &= \left( \frac{1}{6} \right) \left( 518 + \left( \frac{6166}{64} \right)
+ \left( \frac{ 390625} { 64 } \right)
+ 13122 + 4\left( \frac{5764801 } {256 } \right) + 65536 \right) \\
%
S_1 &\doteq \left( \frac{1}{6} \right) \left( 518 + 96.34375 + \left( \frac{ 390625} { 64 } \right)
+ 13122 + \left( \frac{5764801 } {64 } \right) + 65536 \right) \\
%
S_1 &\doteq \left( \frac{1}{6} \right) \left( 518 + 96.34375 + \left( \frac{ 390625} { 64 } \right)
+ 13122 + 90075.016 + 65536 \right) \\
S_1 &\doteq \left( \frac{1}{6} \right) \left( 518 + 96.34375 + 6103.5156 + 13122 + 90075.016 + 65536 \right) \\
S_1 &\doteq \left( \frac{1}{6} \right) \left( 175450.88 \right) \\
S_1 &\doteq 29241.813 \\
\end{align*}

As a partial check, we compute the exact value of the integral.
$$ \int_0^4 x^8 \, dx = \frac{x^9}{9} \Big|_0^4 = \frac{4^9}{9} \doteq 29127.111 $$
Now for the second integral.
\begin{align*}
a &= 4 \\
b &= 5 \\
n &= 4 \\
h &= \frac{b-a}{n} = \frac{5-4}{4} = \frac{1}{4} \\
S_2 &= \left( \frac{h}{3} \right) \left( f(4) + 4f\left( \frac{17}{4} \right) + 2f\left( \frac{18}{4} \right) +
4f\left( \frac{19}{4} \right) + f(5) \right) \\
f(4) &= 4^8 = 65536 \\
S_2 &= \left( \frac{1}{12} \right) \left( 65536 + 4f\left( \frac{17}{4} \right) + 2f\left( \frac{18}{4} \right) +
4f\left( \frac{19}{4} \right) + f(5) \right) \\
f\left( \frac{17}{4} \right) &= \frac{17^8}{4^8} \doteq 106441.61 \\
S_2 &\doteq \left( \frac{1}{12} \right) \left( 65536 + 4( 106441.61 ) + 2f\left( \frac{18}{4} \right) +
4f\left( \frac{19}{4} \right) + f(5) \right) \\
S_2 &\doteq \left( \frac{1}{12} \right) \left( 491302.44 + 2f\left( \frac{18}{4} \right) +
4f\left( \frac{19}{4} \right) + f(5) \right) \\
f\left( \frac{18}{4} \right) &= \left( \frac{ 9}{2} \right)^8 \doteq 168151.25 \\
f\left( \frac{19}{4} \right) &= \left( \frac{ 19}{4} \right)^8 \doteq 259148.61 \\
f(5) &= 5^8 = 390625 \\
S_2 &\doteq \left( \frac{1}{12} \right) \left( 491302.44 + 2( 168151.25 ) + 4( 259148.61 ) + 390625 \right) \\
S_2 &\doteq \left( \frac{1}{12} \right) \left( 2254824.4 \right) \\
S_2 &\doteq 187902.03
\end{align*}

As a partial check, we compute the exact value of the integral.
$$ \int_4^5 x^8 \, dx = \frac{x^9}{9} \Big|_4^5 = \frac{5^9}{9} – \frac{4^9}{9} \doteq 187886.78 $$
Hence:
\begin{align*}
S &\doteq 29241.813 + 187902.03 \\
S &\doteq 217143.84 \\
\end{align*}

As a partial check, we compute the exact value of the integral.
$$ \int_0^5 x^8 \, dx = \frac{x^9}{9} \Big|_0^5 = \frac{5^9}{9} = \frac{1953125 }{ 9} $$
$$ \int_0^5 x^8 \, dx \doteq 217013.89 $$

Best Answer

The idea of splitting an integral into uneven partitions, usually based on how fast the derivative changes, is certainly a used tactic. Specifically in the case of numerical solutions for differential equations, of which numerical integration is a subset of, this is called an adaptive step size.

As for your results, your Simpson approximations ought to have been

$$\int_0^4x^8~\mathrm dx\doteq\frac{2807249}{96}=29242.177083332$$ $$\int_4^5x^8~\mathrm dx\doteq\frac{18471521297}{98304}\doteq187902.03142293$$

so the first likely had an arithmetic error, but the second looks fine.