I understand that correct derivations exist on this site. I am, however, interested in why my workings are incorrect.
Let $f(x)\approx L(x)=\sum_{n=0}^2\ell_n(x)\cdot f(c_i)$, where $c_i$ are three nodes which $L$ interpolates $f$ (quadratically) from. $\ell_n=\prod_{i=0,i\neq n}^2(x-c_i)/(c_n-c_i)$. Then I am told that one can find derive Simpson's Rule by: $\int_a^bf(x)\,dx\approx\int_a^bL(x)\,dx$.
We set the nodes as follows: $c_0=a,c_1=(b-a)/2=m,c_2=b$, $b\gt a$. Then:
$$\int_a^bL(x)\,dx=\sum_{n=0}^2f(c_n)\int_a^b\ell_n(x)\,dx$$
I integrated $\ell_n$ for all $n$, but the expressions I arrived at were too complicated and gave a different approximation to Simpson's Rule.
$$\begin{align}\int_a^b\ell_0(x)\,dx&=\int_a^b\frac{(x-m)(x-b)}{(a-m)(a-b)}\,dx\\&=\frac{1}{2}\left[\frac{(x-b)^2(x-m)}{(a-b)(a-m)}\right]_a^b-\frac{1}{2}\int_a^b\frac{(x-b)^2}{(a-b)(a-m)}\,dx\\&=\frac{1}{2}(b-a)-\frac{1}{2}\left[\frac{1}{3}\frac{(x-b)^3}{(a-b)(a-m)}\right]_a^b\\&=\frac{1}{2}(b-a)+\frac{1}{6}\frac{(a-b)^2}{(a-m)}\\&=\frac{1}{2}(b-a)+\frac{1}{6}\frac{(b-a)^2}{\frac{3}{2}a-\frac{b}{2}}\\&=\frac{1}{2}(b-a)-\frac{1}{3}\frac{(b-a)^2}{b-3a}\end{align}$$
And doing the same for the other $\ell_n$, I get:
$$\begin{align}\int_a^b\ell_0(x)\,dx&=\frac{1}{2}(b-a)-\frac{1}{3}\frac{(b-a)^2}{b-3a}\\\int_a^b\ell_1(x)\,dx&=\frac{2}{3}\frac{(b-a)^3}{(b+a)(b-3a)}\\\int_a^b\ell_2(x)\,dx&=\frac{1}{2}(b-a)-\frac{1}{3}\frac{(b-a)^2}{b+a}\end{align}$$
I should add that my interpolation functions and their integrals are all exact, as corroborated by Desmos numerical integration - I have a graph testing all this here. However, the expression for $\int_a^bL(x)\,dx$ is very different to the expression for Simpson's Rule:
$$\begin{align}\int_a^bf(x)\,dx&\approx\int_a^bL(x)\,dx\\&=\sum_{n=0}^2f(c_n)\cdot\int_a^b\ell_n(x)\,dx\\&=f(a)\cdot\left(\frac{1}{2}(b-a)-\frac{1}{3}\frac{(b-a)^2}{b-3a}\right)+f\left(\frac{b-a}{2}\right)\cdot\frac{2}{3}\frac{(b-a)^3}{(b+a)(b-3a)}\\&+f(b)\cdot\left(\frac{1}{2}(b-a)-\frac{1}{3}\frac{(b-a)^2}{b+a}\right)\\&=\frac{1}{2}(b-a)(f(a)+f(b))-\frac{1}{3}(b-a)^2\left(\frac{f(a)(b+a)+f(b)(b-3a)}{(b-3a)(b+a)}\right)\\&+f\left(\frac{b-a}{2}\right)\cdot\frac{2}{3}\frac{(b-a)^3}{(b+a)(b-3a)}\\\int_a^bf(x)\,dx&\approx\frac{1}{2}(b-a)(f(a)+f(b))\\&+\frac{1}{3}\frac{(b-a)^2}{(b+a)(b-3a)}\left(2f\left(\frac{b-a}{2}\right)(b-a)-f(a)(b+a)-f(b)(b-3a)\right)\end{align}$$
EDIT:
I have caught a fair few typos, but again corroborating with Desmos I believe my expressions are now correct! If you see any more typos please comment them.
OP, cont:
And I have tried for a while (and failed) to simplify this further in any meaningful way.
I wonder two things:
- Is my approximation better, worse (I mean in accuracy, not in terms of complexity - mine loses on efficiency for sure), or just different? (EDIT: some experimentation suggests that it is more accurate!)
- How does one actually get Simpson's Rule from this? It seems like my integration exactly integrates $\int_a^bL(x)\,dx$, so what is Simpson integrating, then?