Course Webpage

Construct and give the degree of precision of:

  • The Midpoint rule.
  • The Trapezoidal rule.

Introduction

Quadrature formulas

Numerical integration or quadrature formulas have the form

$$ \int_{a}^{b}f(x)\,dx\approx \omega_{0}\;f(x_{0})+\omega_{1}\;f(x_{1})+\cdots +\omega_{n}\;f(x_{N}) $$

where $x_{0},x_{1},...,x_{N}$ (nodes) are $N+1$ different points in the interval $[a,b]$ and $\omega_{0},\omega_{1},\ldots ,\omega_{N}$ (weights) are real numbers.

Interpolatory quadrature formulas

If $P_{N}$ is the polynomial interpolation function for $f$ in the nodes $x_{0},x_{1},...,x_{N} \in \left[ a,b\right]$ and

$$ \int_{a}^{b}f(x)\,dx\approx \int_{a}^{b}P_N(x)\,dx=\omega_{0}\,f(x_{0})+\omega_{1}\,f(x_{1})+\cdots +\omega_{n}\,f(x_{N}) $$

this is called an interpolatory quadrature formula.

Simple and composite quadrature formulas

Quadrature formulas are called simple if the approximation takes place in the whole interval $(a,b)$, and composite if, before the application of the formula, we split the interval $(a,b)$, in a given number, $n,$ in a given number,

Degree of precision

The degree of precision is used for simple quadrature formulas. A quadrature formula has degree of precision $r$ if the rule is exact for

$$ f\left( x\right) =1,\quad f\left( x\right) =x,\quad f\left( x\right) =x^{2},...,\quad f\left( x\right) =x^{r}$$

and it is not for $f\left( x\right) =x^{r+1}$

Simple Newton-Cotes formulas

They are interpolatory quadrature formulas where the nodes are equispaced within the interval. There are two types of Newton-Cotes formulas

  • Closed formulas. The integration limits $a$ and $b$ are nodes. For example, the nodes for a closed Newton-Cotes formula of four nodes will be
  • Open formulas. The integration limits $a$ and $b$ are not nodes.

The Midpoint rule

The midpoint rule is

$$\int_{a}^{b}f(x)\,dx\approx (b-a)\;f\left( \frac{a+b}{2}\right)$$

Using the midpoint formula to integrate a function in an interval is equivalent to substituting, within the integral, the function to be integrated by the interpolation polynomial of degree zero, that is, a horizontal line that passes through the midpoint of the function. We replace the function with a line and integrate. We are then calculating the area of a rectangle. For example, given the integral

$$ \int_2^3 \ln x \,dx$$

The Midpoint rule construction

The Midpoint rule is obtained by integrating the polynomial of degree zero that passes through the midpoint of the integration interval. If we write this polynomial in Lagrange form

$$P_{0}(x)=f\left(\frac{a+b}{2}\right)$$

and then $$\int_{a}^{b}f(x)\, dx\approx\int_{a}^{b}P_{0}(x)\, dx=\int_{a}^{b}f\left(\frac{a+b}{2}\right)\, dx=$$

$$=f\left(\frac{a+b}{2}\right)\int_{a}^{b}1\, dx=f\left(\frac{a+b}{2}\right)\left[x\right]_{a}^{b}=f\left(\frac{a+b}{2}\right)\left(b-a\right)$$

Thus, the Midpoint rule is

$$\int_{a}^{b}f(x)\, dx\approx\left(b-a\right)f\left(\frac{a+b}{2}\right)$$

And if we call $h=b-a$ to the length of the integration interval, we can write the formula

$$\int_{a}^{b}f(x)\, dx\approx hf\left(\frac{a+b}{2}\right)$$

that is the area rectangle of base $h$ height $f\left(\dfrac{a+b}{2}\right).$

Degree of precision of the Midpoint rule

For a quadrature formula to be exact for a degree $n$ polynomial $P_{n},$ or has a degree of precision $n$, this formula must be exact for the functions $1$, $x$, $x^{2}$, $\ldots$, $x^{n}$ and not be exact for $x^{n+1}$. Let us check the Midpoint rule

Is it exact for $f(x)=1$? Yes, because

$$\int_{a}^{b}1\, dx=b-a$$

and for this interval and this function the midpoint rule is

$$\left(b-a\right)f\left(\frac{a+b}{2}\right)=\left(b-a\right)1=b-a$$

Is it exact for $f(x)=x$? Yes, because

$$\int_{a}^{b}x\, dx=\frac{b^{2}-a^{2}}{2}$$

and for this interval and this function the midpoint rule is

$$\left(b-a\right)f\left(\frac{a+b}{2}\right)=\left(b-a\right)\frac{a+b}{2}=\frac{\left(b+a\right)\left(b-a\right)}{2}=\frac{b^{2}-a^{2}}{2}$$

Is it exact for $f(x)=x^{2}$? No, because

$$\int_{a}^{b}x^{2}\, dx=\frac{b^{3}-a^{3}}{3}$$

and for this interval and this function the midpoint rule is

$$\left(b-a\right)f\left(\frac{a+b}{2}\right)=\left(b-a\right)\left(\frac{a+b}{2}\right)^{2}=\frac{b^{3}+ab^{2}-a^{2}b-a^{3}}{4}$$

Since it is exact for $1$ and $x$ but not for $x^{2}$, it is exact for polynomials up to degree $1$ but not for degree $2$ and the precision of the formula is 1.

The Trapezoidal rule

The simple Trapezoidal rule is

$$\int_{a}^{b}f(x)dx\approx \frac{b-a}{2}\;\left( f\left( a\right) +f\left( b\right) \right)$$

Using the formula of trapezoids to integrate a function in an interval is equivalent to substituting, within the integral, the function to be integrated by the interpolation polynomial of degree one, which passes through the points of the function at the interval borders. That is, we replace the function with a line and integrate. We are then calculating the area of a trapezoid. For example, given the integral

$$ \int_2^3 \ln x \,dx$$

The Trapezoidal rule construction

The Trapezoid formula is obtained by integrating the polynomial of degree 1 that passes through the borders of the integration interval. If we write this polynomial in Lagrange form and the points are $(a,f(a))$ and $(b,f(b))$

$$P_{1}(x)=f(a)\frac{x-b}{a-b}+f(b)\frac{x-a}{b-a}$$

then

$$\int_{a}^{b}f(x)\, dx\approx\int_{a}^{b}P_{1}(x)\, dx=\frac{f(a)}{a-b}\int_{a}^{b}(x-b)\, dx+\frac{f(b)}{b-a}\int_{a}^{b}(x-a)\, dx=$$

.

$$=\frac{f(a)}{a-b}\left[\frac{(x-b)^{2}}{2}\right]_{a}^{b}+\frac{f(b)}{b-a}\left[\frac{(x-a)^{2}}{2}\right]_{a}^{b}=\frac{f(a)}{a-b}\,\frac{-(a-b)^{2}}{2}+\frac{f(b)}{b-a}\,\frac{(b-a)^{2}}{2}=$$

.

$$=f(a)\,\frac{-(a-b)}{2}+f(b)\,\frac{(b-a)}{2}=\frac{b-a}{2}\left(f(a)+f(b)\right)$$

And the Trapezoidal rule is

$$\int_{a}^{b}f(x)\, dx\approx\frac{b-a}{2}\left(f(a)+f(b)\right)$$

And if we call $h=b-a$ to the length of the integration interval, we can write the formula

$$\int_{a}^{b}f(x)\, dx\approx\frac{h}{2}\left(f(a)+f(b)\right)$$

which is the area of the trapezoid with base $h$ and heights $f(a)$ and $f(b)$ (the area of the trapezoid is the base multiplied by the average of the heights).

The degree of precision of the Trapezoidal rule

For a quadrature formula to be exact for a degree $n$ polynomial $P_{n},$ or has a degree of precision $n$, this formula must be exact for the functions $1$, $x$, $x^{2}$, $\ldots$, $x^{n}$ and not be exact for $x^{n+1}$. Let us check the Trapezoidal rule

Is it exact for $f(x)=1$? Yes, because

$$\int_{a}^{b}1\, dx=b-a$$

and for this interval and this function the Trapezoidal rule is

$$\frac{b-a}{2}\left(f(a)+f(b)\right)=\frac{b-a}{2}\left(1+1\right)=b-a$$

Is it exact for $f(x)=x$? Yes, because

$$\int_{a}^{b}x\, dx=\frac{b^{2}-a^{2}}{2}$$

and for this interval and this function the Trapezoidal rule is

$$\frac{b-a}{2}\left(f(a)+f(b)\right)=\frac{b-a}{2}\left(a+b\right)=\frac{\left(b+a\right)\left(b-a\right)}{2}=\frac{b^{2}-a^{2}}{2}$$

Is it exact for $f(x)=x^{2}$? No, because

$$\int_{a}^{b}x^{2}\, dx=\frac{b^{3}-a^{3}}{3}$$

and for this interval and this function the Trapezoidal rule is

$$\frac{b-a}{2}\left(f(a)+f(b)\right)=\frac{b-a}{2}\left(a^{2}+b^{2}\right)=\frac{b^{3}-ab^{2}+a^{2}b-a^{3}}{2}$$

Since it is exact for $1$ and $x$ but not for $x^{2}$, it is exact for polynomials up to degree $1$ but not for degree $2$ and the precision of the formula is 1.