User:Egm6341.s10.Team4/HW3

= Problem 1: Proof of Tighter Error Bound for Simpson's rule [Simple]=

Given
Refer Lecture slide [[media:Egm6341.s10.mtg17.djvu|17-1]] for problem statement.

From Lecture slide [[media:Egm6341.s10.mtg14.pdf|14-1]], Error for Simple Simpson's rule is given by,


 * {| style="width:90%" border="0" align="center"



\begin{align} E_{2} & = -\frac{(b-a)^5}{2880}f^{(4)}(\xi)\ \, \xi \in [a,b] \\ & = -\frac{h^5}{90}f^{(4)}(\xi)\ \, h := \frac{b-a}{2} \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle \longrightarrow (1)


 * }.
 * }.

In order to prove the above Error for Simple Simpson's rule [ [[media:Egm6341.s10.mtg15.pdf|proof]] ], we defined


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G(t) := e(t) - t^5 e(1)

$$ $$
 * $$\displaystyle \longrightarrow (2)


 * }.
 * }.

where,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

e(t) := \int_{-t}^{+t} F(t)dt - \frac{t}{3} \left[F(-t)+4F(0)+F(t)\right] \ \, F(t) := f(x(t))

$$ $$
 * $$\displaystyle \longrightarrow (3)


 * }.
 * }.

Find
 Part I.  Try to replicate the proof, by using the below equations instead of Equation (2) and point out where the proof breaks down.


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G(t) := e(t) - t^4 e(1)

$$ $$
 * $$\displaystyle \longrightarrow (4)


 * }.
 * }.


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G(t) := e(t) - t^6 e(1)

$$ $$
 * $$\displaystyle \longrightarrow (5)


 * }.
 * }.

''' Part II. ''' Using Equation(2) find $$\displaystyle G^{(3)}(0) $$ and follow the same steps in the proof. Observer what happens.

Solution
 Part I. Using Equation (4):


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G(t) := e(t) - t^4 \underbrace{e(1)}_{Constant}

$$


 * }.
 * }.

On differentiating,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow G^{(1)}(t) = e^{(1)}(t) - 4t^3 e(1)

$$


 * }.
 * }.


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow G^{(2)}(t) = e^{(2)}(t) - 12t^2 e(1)

$$


 * }.
 * }.


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow G^{(3)}(t) = e^{(3)}(t) - 24t e(1)

$$ $$
 * $$\displaystyle \longrightarrow (6)


 * }.
 * }.

From, HW2-Problem-14-Solution and from the lecture slide [[media:Egm6341.s10.mtg15.pdf|15-2]] we know,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

e^{(3)}(t) = -\frac{t}{3} \left[ F^{(3)}(t) - F^{(3)}(-t)\right]

$$ $$
 * $$\displaystyle \longrightarrow (7)


 * }.
 * }.

Applying Rolle's theorem thrice 15-2], we have shown that


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\exists \ \zeta_3 \in \ (0,\zeta_2) \ such\ that\ G^{(3)}(\zeta_3) = 0,

$$ $$
 * $$\displaystyle \longrightarrow (8)


 * }.
 * }.

Substituting Equations (7) and (8) in (6),


 * {| style="width:90%" border="0" align="center"



\begin{align} \Rightarrow G^{(3)}(\zeta_3) &= e^{(3)}(\zeta_3) - 24\zeta_3 e(1) \\ &= -\frac{\zeta_3}{3} \left[ F^{(3)}(\zeta_3) - F^{(3)}(-\zeta_3)\right] - 24\zeta_3 e(1) \\ &= 0 \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle \longrightarrow (9)


 * }.
 * }.

Using DMVT [[media:Egm6341.s10.mtg12.pdf|Derivative Mean Value Theorem, 12-1]], we get


 * {| style="width:90%" border="0" align="center"



\begin{align} \Rightarrow \left[ F^{(3)}(\zeta_3) - F^{(3)}(-\zeta_3) \right] &= \left[ \zeta_3 - (-\zeta_3) \right] F^{(4)}(\zeta_4) \\ &= 2\zeta_3 F^{(4)}(\zeta_4) \end{align} $$ $$
 * $$\displaystyle
 * $$\displaystyle \longrightarrow (10)


 * }.
 * }.

Using Equation (10) in (9),


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow 0 = -\frac{2\zeta_{3}^{2}}{3} F^{(4)}(\zeta_4) - 24\zeta_3 e(1)

$$ $$
 * $$\displaystyle \longrightarrow (11)


 * }.
 * }.

Solving for $$\displaystyle e(1) $$,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow e(1) = -\frac{\zeta_{3}}{36} F^{(4)}(\zeta_4)

$$ $$
 * $$\displaystyle \longrightarrow (12)
 * }.
 * }.

We know from Lecture slide [[media:Egm6341.s10.mtg14.pdf|14-2]],


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

E_{2} = I - I_2 = \frac{b-a}{2}e(1) = h e(1)

$$ $$
 * $$\displaystyle \longrightarrow (13)
 * }.
 * }.

On substituting Equation (12) in (13) gives us,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow E_{2} = - h \frac{\zeta_{3}}{36} F^{(4)}(\zeta_4)

$$ $$
 * $$\displaystyle \longrightarrow (14)
 * }.
 * }.

From the relationship between $\displaystyle \xi$ and $\displaystyle \zeta_4$ we have,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow \displaystyle F^4(\zeta_4)=\frac{(b-a)}{16} ^4\cdot f^4(\xi)

$$ $$
 * $$\displaystyle \longrightarrow (15)
 * }.
 * }.

Equation (14) then becomes,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow E_{2} = - \frac{\zeta_{3}(b-a)^5}{1152} f^{(4)}(\xi)

$$ $$
 * $$\displaystyle \longrightarrow (16)
 * }.
 * }.

This error equation has an extra term $$\displaystyle \zeta_{3} $$ on the numerator as opposed to Equation (1). The proof breaks down in Equation (11), where we expect $$\displaystyle \zeta_{3}^2 $$ to cancel out, only if we had $$\displaystyle -24\zeta_{3}^2 e(1) $$ instead of $$\displaystyle -24\zeta_{3} e(1) $$.

 Part I. Using Equation (5):

On differentiating Equation (5),


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow G^{(3)}(t) = e^{(3)}(t) - 120t^3 e(1)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (17)


 * }.
 * }.

In this case, Equation (11) becomes,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow 0 = -\frac{2\zeta_{3}^{2}}{3} F^{(4)}(\zeta_4) - 120\zeta_3^3 e(1)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (18)


 * }.
 * }.

Solving for $$\displaystyle e(1) $$,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow e(1) = -\frac{1}{180\zeta_{3}} F^{(4)}(\zeta_4)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (19)
 * }.
 * }.

Substituting in Equation (13),


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow E_{2} = - h \frac{1}{180\zeta_{3}} F^{(4)}(\zeta_4)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (20)
 * }.
 * }.

Using Equation (15),


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow E_{2} = -  \frac{(b-a)^5}{5760\zeta_{3}} f^{(4)}(\xi)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (21)
 * }.
 * }.

Here also an extra term $$\displaystyle \zeta_{3} $$ is on the denominator as opposed to Equation (1). The proof breaks down in Equation (18), where we expect $$\displaystyle \zeta_{3}^2 $$ to cancel out, only if we had $$\displaystyle -120\zeta_{3}^2 e(1) $$ instead of $$\displaystyle -120\zeta_{3}^3 e(1) $$.

So in order to have a tighter bound on the Error Equation, we choose $$\displaystyle G(t) $$ to be $$\displaystyle e(t)-t^5 e(1) $$, in which case Equation (11) becomes,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow 0 = -\frac{2\zeta_{3}^{2}}{3} F^{(4)}(\zeta_4) - 60\zeta_3^2 e(1)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (22)


 * }.
 * }.

Here $$\displaystyle \zeta_{3} $$ term cancels out to give,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow e(1) = -\frac{1}{90} F^{(4)}(\zeta_4)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (23)
 * }.
 * }.

and the Error Equation becomes,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow E_{2} = -  \frac{(b-a)^5}{2880} f^{(4)}(\xi)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (24)
 * }.
 * }.

''' Part II. '''

Using Equation (7) in the third derivative of $$\displaystyle G(t) = e(t)-t^5 e(1) $$ we have,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G^{(3)}(t) = -\frac{t}{3} \left[ F^{(3)}(t) - F^{(3)}(-t)\right] - 60t^2 e(1)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (25)


 * }.
 * }.

At $$\displaystyle t = 0$$,


 * {| style="width:90%" border="0" align="center"



\begin{align} \Rightarrow G^{(3)}(0) &= -\frac{0}{3} \left[ F^{(3)}(0) - F^{(3)}(-0)\right] - 60(0)^2 e(1) \\ &= 0
 * $$\displaystyle

\end{align} $$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (26)


 * }.
 * }.

Since $$\displaystyle G^{(3)}(t)$$ is zero at $$\displaystyle t = 0$$ and $$\displaystyle t = \zeta_3$$ [from Equation (8)],


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\exists \ \zeta_4 \in \ (0,\zeta_3) \ such\ that\ G^{(4)}(\zeta_4) = 0,

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (27)


 * }.
 * }.

Please note that, $$\displaystyle (0,\zeta_3) $$ is an open interval and $$\displaystyle \zeta_4 \ne 0 $$ or $$\displaystyle \zeta_4 \ne \zeta_3 $$.

Now on differentiating Equation (25),


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

G^{(4)}(t) = -\frac{1}{3} \left[ F^{(3)}(t) - F^{(3)}(-t)\right] -\frac{t}{3} \left[ F^{(4)}(t) + F^{(4)}(-t)\right] - 120t e(1)

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (28)


 * }.
 * }.

At $$\displaystyle \zeta_4 $$,


 * {| style="width:90%" border="0" align="center"



\begin{align} \Rightarrow G^{(4)}(\zeta_4) &= -\frac{1}{3} \underbrace{\left[ F^{(3)}(\zeta_4) - F^{(3)}(-\zeta_4)\right]}_{2 \zeta_4 F^{(4)}(\zeta_5)} -\frac{\zeta_4}{3} \left[ F^{(4)}(\zeta_4) + F^{(4)}(-\zeta_4)\right] - 120\zeta_4 e(1) \\ &= 0 \end{align} $$ $$
 * $$\displaystyle
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (29)


 * }.
 * }.

where $$\displaystyle \zeta_5 \in [-\zeta_4,\zeta_4]$$.

Solving for $$\displaystyle e(1)$$ we have,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow e(1) = -\frac{1}{180}  F^{(4)}(\zeta_5) - \frac{1}{360} \left[ F^{(4)}(\zeta_4) + F^{(4)}(-\zeta_4)\right]

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (30)


 * }.
 * }.

Using the relationship between $\displaystyle \xi$ and $\displaystyle \zeta_4$ we have,


 * {| style="width:90%" border="0" align="center"




 * $$\displaystyle

\Rightarrow e(1) = -\frac{(b-a)^4}{2880}  f^{(4)}(\xi_2) - \frac{(b-a)^4}{5760} \left[ f^{(4)}(\xi_1) + f^{(4)}(-\xi_1)\right]

$$ $$
 * <p style="text-align:right;">$$\displaystyle \longrightarrow (31)


 * }.
 * }.

where $$\displaystyle \xi_1 = x_1 + h \zeta_4 $$ and $$\displaystyle \xi_2 = x_1 + h\zeta_5 $$, as we know $$\displaystyle x = x_1 + ht $$ from [[media:Egm6341.s10.mtg14.pdf|14-2]].

So, as long as $$\displaystyle f(x) \in \mathcal{P}_{3}$$ we know $$\displaystyle f^{(4)}(x) = 0 $$ from [[media:Egm6341.s10.mtg14.pdf|14-1]].

And for which, $$\displaystyle e(1) = 0 \Rightarrow E_{2} = 0 $$.

Author
Solved and Typed by - Egm6341.s10.Team4.andy 12:41, 17 February 2010 (UTC) .

= Problem 2: Error for composite Simpson's rule =

Given
Use composite Simpson's equation (3) on slide [[media:Egm6341.s10.mtg7.pdf|7-2]], which is:


 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle I_n=\dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)]


 * }
 * }

Find
To demonstrate error of composite Simpson's rule is equal to the following:


 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle 	\left | {E_n}^2\right |\leqslant\dfrac{(b-a)^5}{2880n^4}M_4=\dfrac{(b-a)h^4}{2880}M_4



M_4:=max\left |f^{(4)}(\xi)\right | $$



\xi\in[a,b] $$
 * style= |
 * }.
 * }.

Solution
The error definition can be done as:



{E_n}^2=I-I_n=\int\limits_{a}^{b} f(x)dx-I_n $$

From the composite form of Simpson's rule, we have:



I_n=\dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)] $$



\Rightarrow {E_n}^2=\int\limits_{a}^{b} f(x)dx-\dfrac{h}{3}[f(x_0)+4f(x_1)+2f(x_2)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)]= $$



=\sum_{i=1}^{n/2} [\int\limits_{x_{2i-2}}^{x_{2i}} f(x)dx-\dfrac{h}{3}[f(x_{2i-2})+4f(x_{2i-1})+f(x_{2i})]] $$

where,

h=\frac{b-a}{n} = x_i-x_{i-1} $$

According to Lagrange interpolation error for simple Simpson's rule (refer to [14-1]) for $$\displaystyle [x_{i-1},x_{i+1}] $$ ;



E_2=\dfrac{x_{i+1}-x_{i-1}}{2} f^{(4)}(\xi) $$



\xi\in [x_{i-1},x_{i+1}] $$



\Rightarrow \left |{E_n}^2 \right | \le \sum_{i=1}^{n/2} max \left | \dfrac {(x_{i+1}-x_{i-1})^5}{90\times 2^5} f^{(4)}(\xi)\right | =\dfrac{h^5}{90}\times \sum_{i=1}^{n/2} max \left | f^{(4)}(\xi)\right | $$



h=\dfrac {x_{i+1}-x_{i-1}}{2}=\dfrac {b-a}{n} $$



M_4:=max\left | f^{(4)}(\xi) \right | $$



\xi\in [x_{i-1},x_{i+1}] $$



\overline{M_4}:=\sum_{i=1}^{n/2} max\left |f^{(4)}(\xi) \right | $$



\overline{M_4}\le max\left | \dfrac {n}{2} .M_4 \right | $$



\Rightarrow\left |{E_n}^2\right |\le\dfrac{h^5}{90}\times \dfrac {n}{2}.M_4=\dfrac{h^5}{90}\times \dfrac {\dfrac{b-a}{h}}{2}.M_4 $$


 * {| style="width:20%" border="0"

$$\displaystyle \Rightarrow\left |{E_n}^2\right | \le \dfrac{(b-a)h^4}{180} M_4 $$
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * style="width:20%; padding:10px; border:2px solid #8888aa" |


 * style= |

This answer is different from the asked question, However, this answer is confirmed in the Atkinson's text book "An Intro, Numerical Analysis" 2nd edition (page 257~258)
 * }
 * }

.

Author
Solved and typed by - Egm6341.s10.Team4.nimaa&amp;m 15:31, 17 February 2010 (UTC) Reviewed by - Egm6341.s10.Team4.andy 16:23, 17 February 2010 (UTC) .

= Problem 3: Visualization: Error Estimates' Plots=

Given

 * {| style="width:100%" border="0" align="center"

$$I=\int\limits_{0}^{1} f(x)\, dx$$ $$where f(x)=\frac{(e^x-1)}{x}.$$
 * <p style="text-align:right;">$$\displaystyle $$
 * }.
 * }.

Find

 * {| style="width:100%" border="0" align="center"


 * 1) Find n such that En=I-In is of the order of 10-6 using the error estimates for the Taylor's series, composite Trapezoidal rule, composite Simpson's rule and compare to numerical results.
 * 2) Numerically find the power of h in the error. Plot error versus h on log graph and measure slope.
 * 1) Find n such that En=I-In is of the order of 10-6 using the error estimates for the Taylor's series, composite Trapezoidal rule, composite Simpson's rule and compare to numerical results.
 * 2) Numerically find the power of h in the error. Plot error versus h on log graph and measure slope.


 * <p style="text-align:right;">$$\displaystyle $$
 * }.
 * }.

Solution
The error for Taylor series is analytically given by $$\displaystyle \frac{1}{(n+1)!(n+1)} \leq E_n \leq \frac{e}{(n+1)!(n+1)}$$ The maximum value of En is equal to $$\displaystyle \frac{e}{(n+1)!(n+1)} $$.

The value of the error given in the problem is equal to 10-6.


 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle \frac{e}{(n+1)!(n+1)}= 10^{-6} $$
 * }.
 * }.


 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle (n+1)!(n+1)= e \cdot10^6 $$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle n=8(approximately). $$
 * }.
 * }.

The error for composite Trapezoidal rule is analytically given by $$\displaystyle |E^1_n| \leq \frac{(b-a)^3}{12n^2}M_2$$

where M2 is the maximum of $$\displaystyle f^{''}(x).$$ in the interval [0,1]. $$\Rightarrow a=0,b=1.$$


 * {| style="width:70%" border="0" align="center"




 * Given $$\displaystyle f(x)=\frac{(e^x-1)}{x}.$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow f^'(x)=\frac {xe^x-e^x+1}{x^2}.$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"



Plot: .
 * $$\Rightarrow f^{''}(x)=\frac {x^2e^x-2xe^x+2e^x-2}{x^3}$$
 * }.
 * }.

The above function $$\displaystyle f^{''}(x)$$ is plotted with respect to x in the interval [0,1] and a maximum of 0.72 is obtained at x=1.
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle |E^1_n|=\frac{(b-a)^3}{12n^2}M_2=\frac{M_2}{12n^2}$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle \frac{M_2}{12n^2}=10^{-6}$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle n^2=\frac{0.72*10^6}{12}$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle n=245$$(approximately).
 * }.
 * }.

The error for composite Simpson's rule is analytically given by $$\displaystyle |E^2_n| \leq \frac{(b-a)^5}{180n^4}M_4.$$

where M4 is the maximum of $$\displaystyle f^4(x).$$ in the interval [0,1].


 * {| style="width:70%" border="0" align="center"




 * Given $$\displaystyle f(x)=\frac{(e^x-1)}{x}.$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow f^4(x)=\frac {x^4e^x-4x^3e^x+12x^2e^x-24xe^x+24e^x-24}{x^5}.$$
 * }.
 * }.

Plot: .

The above function $$\displaystyle f^4(x)$$ is plotted with respect to x in the interval [0,1] and a maximum of 0.465 is obtained at x=1.


 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle |E^2_n|=\frac{(b-a)^5}{180n^4}M_4=\frac{M_4}{180n^4}.$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle \frac{M_4}{180n^4}=10^{-6}$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle n^4=\frac{0.465*10^6}{180}$$
 * }.
 * {| style="width:70%" border="0" align="center"
 * {| style="width:70%" border="0" align="center"




 * $$\Rightarrow \displaystyle n=8$$(approximately).
 * }.
 * }.

The above analytical values of n are compared to the numerical values of n for an error of 10-6 which in turn are obtained from the matlab code.

 Matlab Code: for $$ E_{Taylors series} $$ 

 Matlab Code: for $$ E_{n,Trapezoidal} $$ 

 Matlab Code: for $$ E_{n,simpson} $$ 

The values of n obtained numerically for an error of 10-6 are 8,200,8 for Taylors series,trapezoidal rule and Simpson's rule which are almost equal to the values 8,245,8 found analytically.

In the next part we are required to find the convergence of the error and power of h in the error numerically. Hence we plot the values of the error and h on a log plot or alternatively plot the values of log(Error) and log(h) in excel plot using the numerical values.

Semilog Plot: .

Semilog Plot: .

Logarithmic Plot: .

The slope of the line in the above graph is obtained to be equal to 2. This is the required power of h in the error formula for trapezoidal rule.

Semilog Plot: . Logarithmic Plot: .

The slope of the line in the above graph is obtained to be equal to 4. This is the required power of h in the error formula for simpsons rule.

Author
Solved and Typed by - Egm6341.s10.team4.anandankala 13:37, 17 February 2010 (UTC) .

= Problem 4: The Error & Ratio of Trapezoidal & Simpson's rule =

Given
Refer Lecture slide [[media:Egm6341.s10.mtg17.djvu|17-3]] [[media:Egm6341.s10.mtg18.djvu|18-1]]for problem statement.

1)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0} e^xcos(x)\; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

2)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0} e^xcos(x)\; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

3)
 * {| style="width:100%" border="0" align="left"

I = \int^{1}_{0} x^3\sqrt{x} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * {| style="width:100%" border="0" align="left"
 * {| style="width:100%" border="0" align="left"

x\to 0; f^{(4)}(x)\to \infty $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

4)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0}\frac{1}{1+(x-\pi^2)} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

5)
 * {| style="width:100%" border="0" align="left"

I = \int^{1}_{0} \sqrt{x} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

6)
 * {| style="width:100%" border="0" align="left"

I = \int^{2\pi}_{0} e^{cos(x)} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Find
1) $$\displaystyle I = \int^{\pi}_{0} e^xcos(x) \; dx $$

Find the below and make a Table

(i). Compsite Trapozoidal rule $$\displaystyle (I_n) $$ and Error of Trapezoidal$$\displaystyle (E_1) $$ for $$\displaystyle n=2, 4, 8, 16, 32, 64, 128, 256, 512 $$

(ii). The Ratio of Error when $$\displaystyle n $$ is doubled,

(iii). Asymptotic Estimates Ẽ

2) $$\displaystyle I = \int^{\pi}_{0} e^xcos(x) \; dx $$

Find the below and make a Table

(i). $$\displaystyle I_n $$ and Error of Simpson's rule$$\displaystyle (E_2) $$ for $$\displaystyle n=2, 4, 8, 16, 32, 64, 128 $$

(ii). The Ratio of Error when $$\displaystyle n $$ is doubled,

(iii). Asymptotic Estimates Ẽ

3) $$\displaystyle I = \int^{1}_{0} x^3\sqrt x \; dx $$,

4) $$\displaystyle I = \int^{\pi}_{0}\frac{1}{1+(x-\pi^2)} \; dx $$,

5)$$\displaystyle I = \int^{1}_{0} \sqrt{x} \; dx $$,

6)$$\displaystyle I = \int^{2\pi}_{0} e^{cos(x)} \; dx $$

Find the below and make a Table

(i). Error of Trapezoidal$$\displaystyle (E_1) $$ and Simpson's Rule $$\displaystyle (E_2) $$ for $$\displaystyle n=2, 4, 8, 16, 32, 64, 128 $$

(ii). The Ratio of Error when $$\displaystyle n $$ is doubled,

Solution
1)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0} e^xcos(x) \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table are bleow.

 Matlab Code: 

 subfunction f(x) 

 subfunction dff_f(x)  .

2)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0} e^xcos(x) \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table are bleow.

 Matlab Code: 

3)
 * {| style="width:100%" border="0" align="left"

I = \int^{1}_{0} x^3\sqrt x \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table are bleow.

 Matlab Codes for Trapezoidal rule: 

 Matlab Codes for Simpson's rule:  .

4)
 * {| style="width:100%" border="0" align="left"

I = \int^{\pi}_{0}\frac{1}{1+(x-\pi^2)} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table is bleow.

 Matlab Code: 

 subfunction f4(x) 

5)
 * {| style="width:100%" border="0" align="left"

I = \int^{1}_{0} \sqrt{x} \; dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table is bleow.

 Matlab Code: 

 subfunction f5(x) 

6)
 * {| style="width:100%" border="0" align="left"

I = \int^{2\pi}_{0} e^{cos(x)}dx $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

Matlab code and the Result table is bleow.

 Matlab Code: 

 subfunction f6(x)  .

Author
Solved [Sections:1,2,3] by - Egm6341.s10.Team4.roni 14:42, 17 February 2010 (UTC) Solved [Sections:4,5,6] by - Egm6341.s10.Team4.yunseok 15:30, 17 February 2010 (UTC) Typed and reviewed [Sections:2,3] by - Egm6341.s10.Team4.nimaa&amp;m 15:33, 17 February 2010 (UTC) 08:16, 17 February 2010 (UTC) Typed and reviewed [Sections:1,4,5,6] by - Egm6341.s10.Team4.yunseok 15:30, 17 February 2010 (UTC)

.

= Problem 5: Evaluation of a Function Using Rhomberg Interpolation=

Given
Rhomberg interpolation for the composite trapezoidal rule is defined as $$ \displaystyle\ T_k(n)=\frac{2^{2k}T_{k-1}(2n)-T_{k-1}(n)}{2^{2k}-1}$$

Find
We are asked to develop an efficient code that calculates and determines the efficiency of Rhomberg interpolation and compares it to the results to the Taylor Series integration method, using the function $$ \displaystyle\ f(x)=\frac{e^x-1}{x}$$.

Solution
The method for applying the trapezoidal rule has been well defined in previous work, thus it will not be shown again here.

Additionally, each $$ \displaystyle\ f(x_i)$$ was only calculated one time for the entire process, increasing the efficiency of the computation. This was done by calculating $$ \displaystyle\ f(x_i)$$ for a very fine computational domain, and then cherry picking certain point appropriate for the number of points being integrated over.

The Rhomberg interpolation is described above, thus we will move right to out results.

In performing the Rhomberg interpolation, we found that with each additional interpolation of the composite trapezoidal series, an additional level of accuracy was obtained, with a linear return on the level of interpolation. However, even with this increased convergence to the exact solution, Rhomberg interpolation still does not converge nearly as quickly as the Taylor Series approximation of this integral does.

Thus, while the Rhomberg interpolation technique is helpful, the Taylor series method still converges much more quickly as a method of numerical integration.

Figure - Error of Various Integration Methods as a Function of the Number of Sub-Intervals Integrated Over

Code to run calculations -

.

Author
Solved and Typed by -  Egm6341.s10.Team4.riherd 14:38, 17 February 2010 (UTC)

.

= Contributing Members = Egm6341.s10.Team4.riherd 03:11, 17 February 2010 (UTC) - Author of Problems:5 ; Proof Read: 1 Egm6341.s10.Team4.andy 13:01, 17 February 2010 (UTC) - Author of Problems:1 ; Proof Read: 2 Egm6341.s10.Team4.nimaa&m 08:19, 17 February 2010 (UTC) - Author of Problems:2 ; Proof Read: 4 Egm6341.s10.Team4.roni 14:42, 17 February 2010 (UTC) - Author of Problems:2 ; Proof Read: 4 Egm6341.s10.Team4.yunseok 15:31, 17 February 2010 (UTC) - Author of Problems: 4 ; Proof Read: 2,3 Egm6341.s10.team4.anandankala 13:37, 17 February 2010 (UTC)-Author of Problems:3 ; Proof Read: 5