# Newton-Cotes for $n=2$ and $[a,b]=[0,1]$

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.

• en.wikipedia.org/wiki/Lagrange_polynomial – user436658 Oct 23 '20 at 20:06
• Thanks @ProfessorVector I did not know what they were called. There is a lot of useful info on wiki. – Xenusi Oct 23 '20 at 20:09

## 1 Answer

The $$\ell_i$$ are defined by the property that they have degree $$n$$ and satisfy $$\ell_i(x_j)=0$$ for $$j \neq i$$ and $$\ell_i(x_i)=1$$, where $$x_i$$ are the nodes. Such polynomials are called the Lagrange basis.

A more transparent way to introduce them would be to define $$l_i(x)=\prod_{j \neq i} (x-x_j)$$ and then set $$\ell_i(x)=\frac{l_i(x)}{l_i(x_i)}$$.

• Thanks. That is easy to understand. – Xenusi Oct 23 '20 at 20:09