Given a smooth function $f$, we denote $L_{f}$ the Lagrange polynomial of degree less than or equal to $1$ which is equal to $f$ at the points $x_1$ and $x_2$. Define $I_{f} = \int_{-1}^{1} L_{f}(x) \mathop{dx}$ and show that $I_{f} = \int_{-1}^{1} f(x) \mathop{dx}$ if $f$ is a polynomial of degree less than or equal to $3$.
This is a problem that I am stuck trying to solve in preparation for an exam that I have. A hint that I'm given is to decompose $f$ as $qp_{2} + r$ with $q$ and $r$ of degree less than or equal to $1$; however, I have no idea how to proceed.
I have tried many things, but I feel like I'm just going in circles now, and I'm not making any progress. So I would really appreciate some help.
We have $f(x)=L_f(x)+(ax+b)(x-x_1)(x-x_2)$, so $$\int_{-1}^1 f(x)dx-\int_{-1}^1 L_f(x)dx=a\int_{-1}^1 x(x-x_1)(x-x_2)dx+b\int_{-1}^1 (x-x_1)(x-x_2)dx.$$We just need to show this is $0$. Note $\int_{-1}^1x^ndx=0$ whenever $n$ is odd, and $\int_{-1}^1x^ndx=2\int_0^1x^ndx$ whenever $n$ is even. So we just need to check $$-\frac13 a(x_1+x_2)+b\left(\frac13+x_1x_2\right)$$is zero. But $a,\,b$ are arbitrary over the set of $L_f$ consistent with a given $f$, so this only works if $$x_1+x_2=0,\,x_1x_2=-\frac13.$$I think they're expecting you to deduce the choice $x_1=-x_2=\pm\frac{1}{\sqrt{3}}$yields the desired result, i.e. we can obtain especially good numerical integration with something more complicated than the obvious trapezium rule.