Guiding philosophy:
We may approximate this limit numerically by taking a finite sum.
Quadrature rules
So we set out to find nodes $x_0, x_1, \ldots, x_n \in [a, b]$ and
weights $w_0, w_1, \ldots, w_n$ to approximate
$$\int_a^b f(x) dx \color{var(--emphColor)}{\approx} \displaystyle \sum_j w_j f_j,$$
with $f_j = f(x_j)$.
Déjà vu?
$$f'(x_i) \approx \sum_j \alpha_j f_j$$
In the
last module,
we used linear combinations of function values to approximate
the function's derivative.
Here, we'll find which linear combinations of function values
are good approximations to the function's
definite integral!
When computing derivatives or integrals numerically, we approximate
the desired quantity by a weighted sum
of function values, and performing the appropriate operation on the
Lagrange basis polynomials gives the right weight.
When the nodes $x_j$ are given and the weights $\color{var(--emphColor)}{w_j}$
are defined by
integrals of Lagrange basis polynomials, the quadrature rule
$$\int_a^b f(x) dx {\approx} \displaystyle \sum_j \color{var(--emphColor)}{w_j} f_j$$
is a Newton-Cotes (NC) rule.
The rule is said to be closed if
$x_0 = a$ and $x_n = b$.
Otherwise, the rule is said to be open.
Since we are considering equidistant nodes only, the nodes for a
closed rule are
When the rule is open, the nodes are
General Newton-Cotes
To specify an NC rule, we must
Decide whether it is open or closed
Determine $\bbox[3pt, border: 3pt solid var(--emphColor)]{n + 1}$, the number of nodes
Compute $w_j = \int_a^b L_{n,j}(x)dx$, where $L_{j}$ denotes
the $j$th Lagrange basis polynomial.
(Closed NC rule, $\bbox[3pt, border: 3pt solid var(--emphColor)]{n + 1} = 3$)
As usual, let $h = x_{i+1} - x_i$. The rule is closed, so
$x_0 = a$, $x_1 = (a + b)/2$, $x_2 = b$, and $h = (b-a) / 2$.