Solution (source code)

= Solution
{c}

Let $L_{n+1}$ denote the conventional <Legendre polynomial>, normalized by $L_{n+1}(1)=1$. The $n+1$ <quadrature nodes> are its distinct <polynomial roots> in $(-1,1)$. For these nodes form the <Lagrange cardinal polynomials>
$$
\ell_i(x)=\prod_{\substack{0\leq j\leq n\\j\ne i}}
\frac{x-x_j}{x_i-x_j}
=\frac{L_{n+1}(x)}{(x-x_i)L_{n+1}'(x_i)}.
$$
Choose the <quadrature weights> by integrating these <polynomials>:
$$
\boxed{w_i=\int_{-1}^1\ell_i(x)\,dx,\qquad
\widehat I_n(f)=\sum_{i=0}^nw_if(x_i).}
$$
An equivalent standard formula is
$$
\boxed{w_i=\frac{2}{(1-x_i^2)[L_{n+1}'(x_i)]^2}.}
$$
The reason for selecting these <quadrature nodes> is the resulting <degree of precision of a quadrature rule>. For any <polynomial> $p$ of <polynomial degree> at most $2n+1$, <polynomial division> gives
$$
p=L_{n+1}s+r,\qquad \deg s\leq n,\quad\deg r\leq n.
$$
The <orthogonality> of the <Legendre polynomial> makes $\int_{-1}^1L_{n+1}s=0$, while $p(x_i)=r(x_i)$ at each <quadrature node>. The definition of the <quadrature weights> integrates $r$ exactly, so
$$
\boxed{\widehat I_n(p)=\int_{-1}^1p(x)\,dx\qquad(\deg p\leq2n+1).}
$$
In particular, $\sum_iw_i=2$. Applying this exactness to $\ell_i^2$ also proves $w_i=\int_{-1}^1\ell_i(x)^2dx>0$.