Trapezoidal method, deriving error boundary.

264 Views Asked by At

The trapezoid rule on an interval $[a,b]$ is

$$\frac{b-a}{2}(f(a)+f(b))=\int_a^bf(x) \ dx +\frac{f''(\xi)}{12}(b-a)^3, \quad \xi\in[a,b]. \tag i$$

The trapezoid formula is

$$T(h)=h\left[\frac{f(x_0)}{2}+f(x_1)+...+f(x_{n-1})+\frac{f(x_n)}{2}\right],\tag{ii} $$

where $x_i=a+ih$ and $h=(b-a)/n.$

Derive the error boundary

$$|T(h)-I|\le\frac{h^2}{3},$$

where $I=\int_{-1}^1f(x) \ dx$ and $f(x)=e^{-x^2}.$

The solution is the following:

Let $x_0=-1,...,x_i=-1+ih,...,x_n=1,$ where $h=2/n.$ Now we have that

$$ \begin{align} T(h) &=\sum_{i=0}^{n-1}\frac{h}{2}(f(x_i)+f(x_{i+1}))\tag1\\ &=\sum_{i=0}^{n-1}\frac{x_{i+1}-x_i}{2}(f(x_i)+f(x_{i+1}))\tag2\\ &=\sum_{i=0}^{n-1}\left[\int_{x_i}^{x_{i+1}}f(x) \ dx + \frac{f''(\xi)}{12}(x_{i+1}-x_i)^3\right]\tag3\\ &=\int_{-1}^1f(x) \ dx + \sum_{i=0}^{n-1}\frac{f''(\xi)}{12}h^3,\tag4 \end{align} $$

thus

$$ \begin{align} \left|T(h)-\int_{-1}^1f(x) \ dx\right| &=\left|\sum_{i=0}^{n-1}\frac{f''(\xi)}{12}h^3\right|\tag5\\ &\le\sum_{i=0}^{n-1}\left|\frac{f''(\xi)}{12}h^3\right|\tag6\\ &\le\sum_{i=0}^{n-1}\left|\frac{2}{12}h^3\right|= nh\frac{1}{6}h^2=\frac{h^2}{3}\tag7\\ \end{align} $$

Questions:

1) What is happening in the first line? how can $x_0=-1,...,x_i?$

2) I don't understand how they set upp equation $(1)$

3) Going from $(3)$ to $(4)$, how do the integral boundaries change to $-1$ and $1$?

4

There are 4 best solutions below

2
On BEST ANSWER

1) What is happening in the first line? how can $x_0=-1,...,x_i?$

This is just notation, what it means is

\begin{eqnarray} x_0 &=& -1 \\ x_1 &=& -1 + h \\ &\vdots& \\ x_i &=& -1 + ih \\ &\vdots& \\ x_n &=& -1 + nh = -1 + n(2/n) = 1 \end{eqnarray}

2) I don't understand how they set upp equation $(1)$

Consider this graph, the are of one of the area element is the area o trapezium

$$ S_i = \frac{1}{2}(x_{i + 1}- x_{i})(f(x_{i + 1}) + f(x_{i})) = \frac{h}{2} (f(x_{i + 1}) + f(x_{i})) $$

enter image description here

The are is estimated by summing all these elements

$$ S = \sum_i S_i = \sum_i \frac{h}{2} (f(x_{i + 1}) + f(x_{i})) $$

3) Going from $(3)$ to $(4)$, how do the integral boundaries change to $-1$ and $1$?

Remember that

Remember that

$$ \int_{a}^c f(x)~{\rm d}x + \int_{c}^b f(x)~{\rm d}x = \int_{a}^b f(x)~{\rm d}x $$

So that

$$ \int_{x_0=-1}^{x_1} f(x)~{\rm d}x + \int_{x_1}^{x_2} f(x)~{\rm d}x + \cdots + \int_{x_{n-11}}^{x_n=1} f(x)~{\rm d}x = \int_{-1}^{-1} f(x)~{\rm d}x $$

0
On

1)The first line simply writes: $x_i=-1+i \cdot2/n$, for $i = 1,2...,n$.

2)You may "decompose" the trapezoid formula :

$T(h)=h[\frac{f(x_0)}{2}+f(x_1)+...+f(x_{n−1})+\frac{f(x_{n})}{2}]=$

$h[\frac{f(x_0)}{2}+[\frac{f(x_1)}{2}+\frac{f(x_1)}{2}]+...+[\frac{f(x_{n−1})}{2}+\frac{f(x_{n−1})}{2}]+\frac{f(x_{n})}{2}]$

Then pair up $\frac{f(x_{i-1})}{2}$ and $\frac{f(x_i)}{2}$

$h[[\frac{f(x_0)}{2}+\frac{f(x_1)}{2}]+[\frac{f(x_1)}{2}+\frac{f(x_2)}{2}]...+[\frac{f(x_{n−2})}{2}+\frac{f(x_{n−1})}{2}]+[\frac{f(x_{n−1})}{2}+\frac{f(x_{n})}{2}]]$

3)You might have heard of a theorem about integration:

$\int^{c}_{b} f+\int^{b}_{a} f = \int^{c}_{a} f$

Then apply this to 3.

0
On

1) In this case, $[a,b]$ corresponds to $[-1,1]$. Defining $x_i = a + ih, i = 0,1,\dots,n$, with $h = \dfrac{2}{n}$, we then have \begin{align*} x_0 & = -1 + 0(h) = -1 \\ x_n & = -1 + nh = -1 + n\left(\frac{2}{n}\right) = -1 + 2 = 1. \end{align*}

2) This is just an alternative way of writing the trapezoidal rule in summation notation. Simply write out the summation and you should see that this is exactly the trapezoidal rule. Geometrically, $T(h)$ says that we interpolate the function over each subinterval by taking the average of the endpoint values.

3) Going from (3) to (4), we use the definition of $x_i$. More precisely, since $$ [-1,1] = [x_0,x_1]\cup [x_1,x_2]\cup \dots \cup [x_{n-1},x_n], $$ we have that \begin{align*} \sum_{i=0}^{n-1}\int_{x_i}^{x_{i+1}} f(x)dx & = \int_{x_0}^{x_1} f(x)dx + \int_{x_1}^{x_2} f(x)dx + \dots + \int_{x_{n-1}}^{x_n} f(x)dx \\ & = \int_{[x_0,x_1]\cup[x_1,x_2]\cup\dots\cup[x_{n-1},x_n]} f(x)dx \\ & = \int_{x_0}^{x_n} f(x)dx \\ & = \int_{-1}^1 f(x)dx. \end{align*}

0
On

Please rename the two equations from the exercise with anything other than $1$ and $2$. It is a little confusing to have two equations with the same tag, twice. In eq. $(2)$, you have $f(x_1)$ instead of $f(x_i)$ inside the summation.

$1)$ That is just notation for \begin{align} x_0&=-1,\\ x_1&=-1+h,\\ x_2&=-1+2h,\\ &\vdots\\ x_i&=-1+i\,h,\\ &\vdots\\ x_{n-1}&=-1+(n-1)\,h,\\ x_n&=-1+n\,h=-1+n(2/n)=1. \end{align}

$2)$ Equation $(1)$ was set up from the trapezoid formula:

\begin{align} T(h) &=h\left[\frac{f(x_0)}{2}+\color{red}{f(x_1)}+...+\color{blue}{f(x_{n-1})}+\frac{f(x_n)}{2}\right]\\ &=h\left[\frac{f(x_0)}{2}+\color{red}{\frac{f(x_1)}{2}+\frac{f(x_1)}{2}}+...+\color{blue}{\frac{f(x_{n-1})}{2}+\frac{f(x_{n-1})}{2}}+\frac{f(x_n)}{2}\right]\\ &=h\left[ \frac{f(x_0)+f(x_1)}2 +\frac{f(x_1)+f(x_2)}2 +\ldots\right.\\ &\qquad\qquad \left. +\frac{f(x_{n-2})+f(x_{n-1})}2 +\frac{f(x_{n-1})+f(x_n)}2 \right]\\ &= \sum_{i=0}^{n-1} \frac h2 \big(f(x_i)+f(x_{i+1})\big). \end{align}

$3)$ Recall that $x_0=-1$ and $x_n=1$. So, $$\sum_{i=0}^{n-1} \int_{x_i}^{x_{i+1}} =\int_{x_0}^{x_1} +\int_{x_1}^{x_2} +\ldots +\int_{x_{n-2}}^{x_{n-1}} +\int_{x_{n-1}}^{x_n} =\int_{x_0}^{x_n} =\int_{-1}^1.$$