# Deriving error for uncorrected composite trapezoidal method

Show that the error in the uncorrected composite trapezoidal method can be written as $$E(f) = I_f - I_{tr} = K_1h^2 + O(h^4)$$ Where $$K_1$$ is independent of $$h$$, $$I_f$$ is the integral of our original function, and $$I_{tr}$$ is the approximation using composite trapezoidal method.

So for starters, I have no idea what the uncorrected composite trapezoidal method is. The previous problem only asked to derive the corrected composite trapezoidal method, which was found to be $$I_{trc} = I_{tr} + \frac{h^2}{12}[f'(a)-f'(b)]$$ I have a solution given, but do not understand how the pieces are being put together.

The solution:

The desired result follows from the above by simply viewing the first term in the error expansion for the trapezoidal method as the correction term in the corrected trapezoidal method. Thus, the error in the composite trapezoidal method can be written as $$E(f) = I - I_{tr} = \frac{h^2}{12}[f'(b)-f'(a)]-\frac{f''''(\eta)(b-a)}{720}h^4$$

I do not know where that fourth derivative term came from nor why this relation works. If anyone could elaborate more on this solution, it would be greatly appreciated. Thank you

## Construction of the approximation formula

Let's first consider the symmetric standard situation of an interval $$[-r,r]$$. Let $$F$$ be an integral function of $$f$$ and consider the Taylor expansion of $$F(0)$$ at $$x=\pm r$$, so somehow reverse of the usual situation. $$F(0)=F(\pm r)\mp f(\pm r)r+\frac12f'(\pm r)r^2\mp\frac16f''(\pm r)r^3+\frac1{24}f'''(0)r^4\mp\frac1{120}f^{(4)}(\pm r)r^5+O(r^6).$$ In the difference we get $$0=\int_{-r}^r f(x)\,dx - [f(r)+f(-r)]r + \frac12[f'(r)-f'(-r)]r^2 - \frac16[f''(r)+f''(-r)]r^3+\frac1{24}[f'''(r)-f'''(-r)]r^4 - \frac1{120}[f^{(4)}(r)+f^{(4)}(-r)]r^5+O(r^6)$$ Now one can consider $$\frac12[f''(r)+f''(-r)](2r)$$ as trapezoidal formula for its integral $$f'(r)-f'(-r)$$, $$[f''(r)+f''(-r)]r = [f'(r)-f'(-r)]+\frac12[f'''(r)-f'''(-r)]r^2-\frac16[f^{(4)}(r)+f^{(4)}(-r)]r^3+O(r^4)$$ The same way, $$f'''(r)-f'''(-r)=[f^{(4)}(r)+f^{(4)}(-r)]r+O(r^2)$$ Now insert backwards \begin{align} [f''(r)+f''(-r)]r &= [f'(r)-f'(-r)]+\frac13[f^{(4)}(r)+f^{(4)}(-r)]r^3+O(r^4) \\ \int_{-r}^r f(x)\,dx &= [f(r)+f(-r)]r - \left(\frac12-\frac16\right)[f'(r)-f'(-r)]r^2 +\left(\frac1{18}-\frac1{30}\right)[f^{(4)}(r)+f^{(4)}(-r)]r^5+O(r^6) \\ &=[f(r)+f(-r)]r -\frac13[f'(r)-f'(-r)]r^2+\frac1{45}[f^{(4)}(r)+f^{(4)}(-r)]r^5+O(r^6) \end{align}

## Exact derivation of the approximation error

One could now conjecture that a more precise treatment of the remainder terms will give a last term $$\frac{2}{45}f^{(4)}(\rho)r^5$$ for some $$\rho\in (-r,r)$$. Another way to confirm this is to take the remainder formula and compute its Taylor expansion.

Set $$e(r)=\int_{-r}^r f(x)\,dx - [f(r)+f(-r)]r + \frac13[f'(r)-f'(-r)]r^2.$$ Then its derivatives are \begin{align} e'(r)&=-\frac13[f'(r)-f'(-r)]r+\frac13[f''(r)+f''(-r)]r^2,&e'(0)&=0, \\ e''(r)&=-\frac13[f'(r)-f'(-r)]+\frac13[f''(r)+f''(-r)]r+\frac13[f'''(r)-f'''(-r)]r^2,&e''(0)&=0, \\ e'''(r)&=[f'''(r)-f'''(-r)]r+\frac13[f^{(4)}(r)+f^{(4)}(-r)]r^2,&e'''(0)&=0, \\ e^{(4)}(r)&=[f'''(r)-f'''(-r)]+\frac53[f^{(4)}(r)+f^{(4)}(-r)]r+\frac13[f^{(5)}(r)-f^{(5)}(-r)]r^2,&e^{(4)}(0)&=0, \\ e^{(5)}(r)&=\frac83[f^{(4)}(r)+f^{(4)}(-r)]+\frac73[f^{(5)}(r)-f^{(5)}(-r)]r +\frac13[f^{(6)}(r)+f^{(6)}(-r)]r^2,&e^{(5)}(0)&=\frac{16}3f^{(4)}(0), \end{align} Employing the extended mean value theorem one finds intermediate points $$r>r_1>r_2>r_3>|r_4|$$ with \begin{align} \frac{e(r)}{r^5}&=\frac{e'(r_1)}{5r_1^4}=\frac{e''(r_2)}{20r_2^3}=\frac{e'''(r_3)}{60r_3^2} \\ &=\frac{f'''(r_3)-f'''(-r_3)}{60r_3}+\frac{f^{(4)}(r_3)+f^{(4)}(-r_3)}{180} \\ &=\frac{f^{(4)}(r_3)+6f^{(4)}(r_4)+f^{(4)}(-r_3)}{180} \end{align} By the intermediate value theorem of continuous functions there is some $$\rho\in(-r,r)$$ so that $$f^{(4)}(r_3)+6f^{(4)}(r_4)+f^{(4)}(-r_3)=8f^{(4)}(ρ) \implies e(r)=\frac2{45}f^{(4)}(ρ)r^5$$ Now note that in shifting and scaling this formula to the subdivision of the interval we have $$r=\frac h2$$, giving a combined error term of $$\frac{h^5}{720}\sum_{k=1}^nf^{(4)}(ρ_k)=\frac{h^5}{720}nf^{(4)}(\eta)=\frac{h^4(b-a)}{720}f^{(4)}(\eta),$$ the next-to-last again by the intermediate value theorem for $$y=\frac1n\sum_{k=1}^nf^{(4)}(ρ_k)\in[\min_{x\in[a,b]}f^{(4)}(x),\max_{x\in[a,b]}f^{(4)}(x)].$$

• I am delighted to see this proof. It is a nice supplement this note Jan 16 '20 at 22:27

We could prove the trapezoidal rule with correction terms by verifying that it is exact over the interval $$[a,b]$$ for $$P_0(x)=1$$, $$P_1(x)=x-a$$, $$P_2(x)=(x-a)^2$$, and $$P_3(x)=(x-a)^2(b-x)$$ and then since it is therefore exact for all polynomials in $$\mathcal{P}_3$$ we seek an error term of the form $$C(b-a)^5f^{(4)}(\xi)$$. On testing $$P_4(x)=(x-a)^2(b-x)^2$$ we find that $$C=\frac1{720}$$.
Unfortunately this is one of those rare cases where the quantitative part of the theorem, i.e. the value of $$C$$, is much easier to prove than the qualitative part, that the error takes on the form assumed. In fact for many closely related problems the error doesn't take on this form so we want a brute force method to establish the error term from scratch.
Let $$F^{\prime}(x)=f(x)$$ be any primitive of $$f(x)$$. Then \begin{align}F(b)-F(a)&=\int_a^bf(x)dx=-\left.(b-x)f(x)\right|_a^b+\int_a^b(b-x)f(x)dx\\ &=(b-a)f(a)-\left.\frac12(b-x)^2f^{\prime}(x)\right|_a^b+\frac12\int_a^b(b-x)^2f^{\prime\prime}(x)dx\\ &=(b-a)f(a)+\frac12(b-a)^2f^{\prime}(a)-\left.\frac16(b-x)^3f^{\prime\prime}(x)\right|_a^b+\frac16\int_a^b(b-x)^3f^{\prime\prime\prime}(x)dx\\ &=(b-a)f(a)+\frac12(b-a)^2f^{\prime}(a)+\frac16(b-a)^3f^{\prime\prime}(a)-\left.\frac1{24}(b-x)^4f^{\prime\prime\prime}(x)\right|_a^b+\frac1{24}\int_a^b(b-x)^4f^{(4)}(x)dx\\ &=(b-a)f(a)+\frac12(b-a)^2f^{\prime}(a)+\frac16(b-a)^3f^{\prime\prime}(a)+\frac1{24}(b-a)^4f^{\prime\prime\prime}(a)+\frac1{24}\int_a^b(b-x)^4f^{(4)}(x)dx\end{align} This is just the fourth order Taylor polynomial for $$F(b)$$ expanded about $$x=a$$, with an error term established by integration by parts. Similarly we can derive $$f(b)-f(a)=(b-a)f^{\prime}(a)+\frac12(b-a)^2f^{\prime\prime}(a)+\frac16(b-a)^3f^{\prime\prime\prime}(a)+\frac16\int_a^b(b-x)^3f^{(4)}(x)dx$$ and $$f^{\prime}(b)-f^{\prime}(a)=(b-a)f^{\prime\prime}(a)+\frac12(b-a)^2f^{\prime\prime\prime}(a)+\frac12\int_a^b(b-x)^2f^{(4)}(x)dx$$ We can solve the above for $$F(b)$$, $$f(b)$$, and $$f^{\prime}(b)$$ in terms of $$F(a)$$, $$f(a)$$, $$f^{\prime}(a)$$, $$f^{\prime\prime}(a)$$, $$f^{\prime\prime\prime}(a)$$, and integrals to get $$F(b)-F(a)-\frac{(b-a)}2f(a)-\frac{(b-a)}2f(b)-\frac{(b-a)^2}{12}f^{\prime}(a)+\frac{(b-a)^2}{12}f^{\prime}(b)=\\ \begin{array}{rlllll}&(b-a)f(a)&+\frac{(b-a)^2}2f^{\prime}(a)&+\frac{(b-a)^3}6f^{\prime\prime}(a)&+\frac{(b-a)^4}{24}f^{\prime\prime\prime}(a)&+\frac1{24}\int_a^b(b-x)^4f^{(4)}(x)dx\\ &-\frac{(b-a)}2f(a)&&&&\\ &-\frac{(b-a)}2f(a)&-\frac{(b-a)^2}2f^{\prime}(a)&-\frac{(b-a)^3}4f^{\prime\prime}(a)&-\frac{(b-a)^4}{24}f^{\prime\prime\prime}(a)&-\frac{(b-a)}{12}\int_a^b(b-x)^3f^{(4)}(x)dx\\ &&-\frac{(b-a)^2}{12}f^{\prime}(a)&&&\\ &&+\frac{(b-a)^2}{12}f^{\prime}(a)&+\frac{(b-a)^3}{12}f^{\prime\prime}(a)&+\frac{(b-a)^4}{24}f^{\prime\prime\prime}(a)&+\frac{(b-a)^2}{24}\int_a^b(b-x)^2f^{(4)}(x)dx\end{array} \\=\frac1{24}\int_a^b(b-x)^2(x-a)^2f^{(4)}(x)dx$$ Now, since the Peano kernel $$\frac1{24}(b-x)^2(x-a)^2\ge0$$ It follows that \begin{align}\frac1{24}\min_{a\le x\le b}f^{(4)}(x)\int_a^b(b-x)^2(x-a)^2dx&\le\frac1{24}\int_a^b(b-x)^2(x-a)^2f^{(4)}(x)dx\\ &\le\frac1{24}\max_{a\le x\le b}f^{(4)}(x)\int_a^b(b-x)^2(x-a)^2dx\end{align} Assuming continuity of $$f^{(4)}(x)$$ on $$[a,b]$$, using the intermediate value theorem, and evaluating the integral we get $$I-I_{trc}=\frac{(b-a)^5}{720}f^{(4)}(\xi)$$ for some $$a<\xi. Now, that's for the simple trapezoidal rule with correction. For the compound rule, $$b-a=h=x_i-x_{i-1}$$ will now be the width of each subinterval so summing over all subintervals $$\sum_{i=1}^n\left\{F(x_i)-F(x_{i-1})-\frac{h}2f(x_{i-1})-\frac{h}2f(x_i)-\frac{h^2}{12}f^{\prime}(x_{i-1})+\frac{h^2}{12}f^{\prime}(x_i)\right\}\\ \begin{array}{rl}&=F(x_n)-F(x_0)-\frac h2f(x_0)-h\sum_{i=1}^{n-1}f(x_i)-\frac h2f(x_n)-\frac{h^2}{12}f^{\prime}(x_{0})+\frac{h^2}{12}f^{\prime}(x_n)\\ &=F(b)-F(a)-\frac h2f(a)-h\sum_{i=1}^{n-1}f(a+ih)-\frac h2f(b)-\frac{h^2}{12}f^{\prime}(a)+\frac{h^2}{12}f^{\prime}(b)\\ &=\sum_{i=1}^n\frac{h^5}{720}f^{(4)}\left(\xi_i\right)=\frac{h^4(b-a)}{720}\frac1n\sum_{i=1}^nf^{(4)}\left(\xi_i\right)\end{array}$$ Where each $$x_{i-1}<\xi_i. Since the arithmetic mean of a set of values of a continuous function in an interval must be some value of the same continuous function in the same interval by the intermediate value theorem, we get $$I-I_{tr}-\frac{h^2}{12}f^{\prime}(a)+\frac{h^2}{12}f^{\prime}(b)=\frac{h^4(b-a)}{720}f^{(4)}(\eta)$$ For some $$a<\eta. Note that your formula in the second box has a couple of signs wrong.