Using Newton-Cotes formula:
$$ \int_{a}^{b} f(x) d x \approx \int_{a}^{b} p(x) d x=\sum_{i=0}^{n} f\left(x_{i}\right) \int_{a}^{b} \ell_{i}(x) d x $$
I want show that:
$$ \int_{0}^{1} f(x) d x \approx \frac{1}{6} f(0)+\frac{2}{3} f\left(\frac{1}{2}\right)+\frac{1}{6} f(1) $$
I have that $n=1$ and $[a,b]=[0,1]$. First the $\ell_i$ are constructed as follows:
$$ \ell_{0}(x)=2\left(x-\frac{1}{2}\right)(x-1) \quad \ell_{1}(x)=-4 x(x-1) \quad \ell_{2}(x)=2 x\left(x-\frac{1}{2}\right) $$
My question is: how are these $\ell_i$ constructed? It is clear that with this choice se of $\ell_i$ I will get the desired. But I'm not sure how one would construct them. This is from an example in my book.