User:Egm6341.s2010.Team1/HW3

=Problem 17-1=

Find
Where does the proof for bounding the error of the simple Simpson's rule break down?

Given
1) $$G(t):= e(t)-t^4e(1) \,$$

2) $$G(t):= e(t)-t^6e(1) \,$$

3) $$G(t):= e(t)-t^5e(1) \,$$, where for this case continue differentiating to get $$G^{(3)}(0) \,$$

Solution
Start by performing derivatives of $$e(t) \,$$,


 * $$e^{(0)}(t)=\int_{-t}^{t}F(t)dt - \frac{t}{3}[F(-t)+4F(0)+F(t)]$$
 * $$e^{(1)}(t)=F(-t)+F(t)-\frac{1}{3}[F(-t)+4F(0)+F(t)]-\frac{t}{3}[-F^{(1)}(-t)+F^{(1)}(t)]$$
 * $$e^{(2)}(t)=\frac{1}{3}[-F^{(1)}(-t)+F^{(1)}(t)]-\frac{t}{3}[F^{(2)}(-t)+F^{(2)}(t)]$$
 * $$e^{(3)}(t)=-\frac{t}{3}[-F^{(3)}(-t)+F^{(3)}(t)]$$
 * $$e^{(4)}(t)=-\frac{1}{3}[-F^{(3)}(-t)+F^{(3)}(t)]-\frac{t}{3}[F^{(4)}(-t)+F^{(4)}(t)]$$

Note that $$e^{(n)}(0)=0 \,$$ for $$n=0,1,2,3,4 \,$$.

Case 1:


 * $$G^{(2)}(t)=e^{(2)}(t)-12t^2e(1) \,$$

and,
 * $$G^{(2)}(0)=0 \,$$

Plugging in $$\zeta_2 \,$$,
 * $$G^{(2)}(\zeta_2)=\frac{1}{3}\underbrace{[-F^{(1)}(-\zeta_2)+F^{(1)}(\zeta_2)]}_{2\zeta_2F^{(2)}(\zeta_3)}-\frac{\zeta_2}{2}[F^{(2)}(-\zeta_2)+F^{(2)}(\zeta_2)]-12\zeta_2^2e(1)=0$$

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


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


 * style="width:50%; padding:10px; border:2px solid #8888aa" |
 * $$ \displaystyle
 * $$ \displaystyle

e(1)=\frac{1}{18\zeta_2}F^{(2)}(\zeta_3)-\frac{1}{36}F^{(2)}\underbrace{(-\zeta_2)}_{problem}-\frac{1}{36}F^{(2)}(\zeta_2) $$ This variable is not on the interval between 0 and $$\zeta_2 \,$$ $$
 * $$\displaystyle
 * }
 * }

Case 2:


 * $$G^{(4)}(t)=e^{(4)}(t)-360t^2e(1) \,$$

and,
 * $$G^{(4)}(0)=0 \,$$

Plugging in $$\zeta_4 \,$$
 * $$G^{(4)}(\zeta_4)=-\frac{1}{3}[-F^{(3)}(-\zeta_4)+F^{(3)}(\zeta_4)]-\frac{\zeta_4}{3}[F^{(4)}(-\zeta_4)+F^{(4)}(\zeta_4)]-360(\zeta_4^2)e(1)=0 \,$$

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


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


 * style="width:50%; padding:10px; border:2px solid #8888aa" |
 * $$ \displaystyle
 * $$ \displaystyle

e(1)=\frac{-1}{540\zeta_4}F^{(4)}(\zeta_5)-\frac{1}{1080\zeta_4}[F^{(4)}(\underbrace{-\zeta_4)}_{problem}+F^{(4)}(\zeta_4)] $$ This variable is not on the interval between 0 and $$\zeta_4 \,$$ $$
 * $$\displaystyle
 * }
 * }

Case 3:


 * $$G^{(3)}(t)=e^{(3)}(t)-60t^2e(1) \,$$

and,
 * $$G^{(3)}(0)=0 \,$$

We continue taking derivatives of $$G \,$$
 * $$G^{(4)}(t)=e^{(4)}(t)-120te(1) \,$$

to get,
 * $$G^{(4)}(\zeta_4)=-\frac{1}{3}[-F^{(3)}(-\zeta_4)+F^{(3)}(\zeta_4)]-\frac{\zeta_4}{3}[F^{(4)}(-\zeta_4)+F^{(4)}(\zeta_4)]-120(\zeta_4^2)e(1)=0 \,$$

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


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


 * style="width:50%; padding:10px; border:2px solid #8888aa" |
 * $$ \displaystyle
 * $$ \displaystyle

e(1)=\frac{-3}{360}F^{(4)}(\zeta_4)-\frac{1}{360}F^{(4)}\underbrace{(-\zeta_4)}_{problem} $$ This variable is not on the interval between 0 and $$\zeta_4 \,$$ $$ EGM6341.s10.Team1.Kumanchik 19:30, 17 February 2010 (UTC)
 * $$\displaystyle
 * }
 * }

=Problem 17-2(1)=

=Problem 17-2(2)=

Find
Using three numerical integration methods (Taylor series expansion, Simpson's rule, trapezoidal rule) find at what iteration (n) the error approaches an order of 1e-6

Given
$$f(x)= \frac{e^x - 1}{x}$$

Solution
In general there error of a numerical integration is the exact integral minus the numerical integral:


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle E_n=I-I_n
 * }
 * }

For the Taylor series error is just the integral of the remainder term which is


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle R_n(x)=e^{\xi }\frac{x^n}{(n+1)!}
 * }
 * }

Then from p.7-1:


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

$$  \displaystyle \int_{0}^{1}[f(x)-f_n(x)]dx=e^{\xi } \int_{0}^{1}\frac{x^n}{(n+1)!}dx $$    (3) Completing the integration gives
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


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

$$ $$ Choosing $$\xi=0,1$$ then the error is bounded
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle e^{\xi }\frac{1}{(n+1)!(n+1)}
 * }
 * }


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle \frac{1}{(n+1)!(n+1)} 16-3:
 * {| style="width:100%" border="0" align="left"

$$ $$ where
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle \left | E_n^1 \right |\leq \frac{(b-a)}{12n^2}M_2
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$ for
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle M_2 = max | f^{(2)} (\xi )|
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$ Here
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle \xi \varepsilon [a,b]
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$ the max occurs at $$\xi = 1$$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle f^{(2)}=\frac{(x^2-2x+2)e^x-2}{x^3}
 * }
 * }

Finally for the Simpson's rule:
 * {| style="width:100%" border="0" align="left"

$$ $$ where
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle \left | E_n^2 \right |\leq \frac{(b-a)^5}{2880n^4}M_4
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$ for
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle M_4 = max | f^{(4)} (\xi )|
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$ and
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle \xi \varepsilon [a,b]
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle f^{(4)}=\frac{(x^4-4x^3-24x+24)e^x-24}{x^5}
 * }
 * }

Using these three MATLAB codes:

the results below were obtained:

$$ \begin{array}{|c||c|c|c|} n & E_n^{Trap} & E_n^{Taylor} & E_n^{Simpson} \\ \hline 1&0.059900000&0.679600000&0.000161300\\ 2&0.007500000&0.151000000&0.000010081\\ 3&0.002200000&0.028300000&0.000001991\\ 4&0.000935260&0.004500000&--\\	5&0.000478850&0.000629230&--\\	6&0.000277110&0.000077049&--\\	7&0.000174510&0.000008427&--\\	8&0.000116910&--&--\\		9&0.000082108&--&--\\		10&0.000059857&--&--\\		11&0.000044971&--&--\\	12&0.000034639&--&--\\		13&0.000027245&--&--\\	14&0.000021814&--&--\\		15&0.000017735&--&--\\		16&0.000014613&--&--\\		17&0.000012183&--&--\\		18&0.000010264&--&--\\		19&0.000008727&--&--\\ \hline \end{array} $$

From this table it can be seen that the Simpson's rule for numerical integration seems to be the best in that it gives an accurate answer in minimal spatial steps --Egm6341.s10.team1.toddmock 19:50, 17 February 2010 (UTC)

=Problem 17-2(3)=

Find
Plot the step size (h) against the integration error in such a way as to determine a power relation between the two

Solution
Plotting the Log of the step size (h) against the log of the error is most appropriate here because the plot will be a straight line. From the fit equation:


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle Log(E_n)=a[Log(h)]+b


 * }
 * }

it can then be shown that the slope (a) becomes the power term on h.


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle 10^{Log(E_n)}=10^{a(log(h))+b}


 * }
 * }


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle\Rightarrow E_n=10^bh^a

Thus it can be seen in the plots that for the Trapezoidal rule
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle E_n\propto h^3


 * }
 * }

and for the Simpson's rule


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle E_n\propto h^4


 * }
 * }



$$ \begin{array}{|c||c|c|} n & Log(h) & Log(E_n) \\ \hline 1&0.000000&1.2228864\\ 2&0.301030&2.1259764\\ 3&0.477121&2.6542501\\ 4&0.602060&3.0290663\\ 5&0.698970&3.3197964\\ 6&0.778151&3.5573401\\ 7&0.845098&3.7581805\\ 8&0.903090&3.9321563\\ 9&0.954243&4.0856139\\ 10&1.000000&4.2228864\\ \hline \end{array} $$



$$ \begin{array}{|c||c|c|} n & Log(h) & Log(E_n) \\ \hline 1&0.00000&3.792372685\\ 2&0.30103&4.996492668\\ 3&0.47712&5.700857704\\ 4&0.60206&6.200612651\\ 5&0.69897&6.588252703\\ 6&0.77815&6.904977687\\ 7&0.84510&7.172764845\\ 8&0.90309&7.404732633\\ 9&0.95424&7.609342723\\ 10&1.00000&7.792372685\\ \hline \end{array} $$

--Egm6341.s10.team1.toddmock 19:50, 17 February 2010 (UTC)

=Problem 17-3(1-2) 18-1(3-6)=

Find
Reproduce Table 5.1, Table 5.3, Table 5.4, Table 5.5, Table 5.6 and Table 5.7 in text book(Atkinson)

Consider Trapezoidal and Simpson integration

Solution

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


 * Ref: Lecture Notes [[media:Egm6341.s10.mtg7.pdf|P7-1]] [[media:Egm6341.s10.mtg7.pdf|P7-2]]
 * }
 * }

i Table 5.1

ii Table 5.3

iii Table 5.4

iv Table 5.5

v Table 5.6

vi Table 5.7

MATLAB
i    Table 5.1
 * For In


 * For En


 * For Ratio


 * For E'n

ii    Table 5.3
 * For In


 * For En


 * For Ratio


 * For E'n

iii    Table 5.4
 * For Trapezoidal Rule Error


 * For Trapezoidal Rule Ratio


 * For Simpson's Rule Error


 * For Simpson's Rule Ratio

iv    Table 5.5
 * For Trapezoidal Rule Error


 * For Trapezoidal Rule Ratio


 * For Simpson's Rule Error


 * For Simpson's Rule Ratio

v    Table 5.6
 * For Trapezoidal Rule Error


 * For Trapezoidal Rule Ratio


 * For Simpson's Rule Error


 * For Simpson's Rule Ratio

vi    Table 5.7
 * For Trapezoidal Rule Error


 * For Trapezoidal Rule Ratio


 * For Simpson's Rule Error


 * For Simpson's Rule Ratio

EGM6341.s10.Team1.Ya-Chiao Chang 06:54, 17 February 2010 (UTC)

=Problem 19-1=

Find
a) Modify matlab code to make the comp. of $$ T_{0}\left ( 2^j \right )\,$$ efficient, i.e,$$ T_{0}\left ( 2^j \right )=T_{0}\left (2^{(j-1)}\right )+...\,$$

b) Romberg table, compare to previous results

Given
Cont'd  [[media:Egm6341.s10.mtg6.pdf|Lec. 6-5]]
 * {| style="width:100%" border="0" align="left"


 * $$\displaystyle f(x)= \frac{e^x-1}{x} $$
 * $$\displaystyle I= \int\limits_{0}^{1}\frac{e^x-1}{x}\, dx $$
 * }
 * }
 * }

Solution
a) From


 * $$ T(2n)\,$$ comp. based on $$ T(n)\,$$, and $$ f(x_i), i=1,3,5,...\,$$


 * $$ T(n)=h [1/2f_0+f_1+f_2+...+f_{n-1}+1/2f_n], h=(b-a)/n \,$$


 * $$ T(2n)=\underbrace{\left (h [1/2f_0+f_2+f_4...+f_{2(n-1)}+1/2f_n]\right)}_{T(n)}+h [f_1+f_3+f_5+...+f_{2n-1}], h=(b-a)/2n \,$$


 * $$\Rightarrow T_{0}\left ( 2^j \right )= T_{0}\left (2^{(j-1)}\right )+ (b-a)/2n [f_1+f_3+f_5+...+f_{2(j-1)}] \,$$

Based on this method,modify matlab code to make the comp.of $$ T_{0}\left ( 2^j \right )\,$$ efficient.

Modified Matlab Code:

b) Romberg table display the results as follows:

Previous results:

From the comparation, for a given value of n,the most accurate value is for the largest value of k.

Matlab Code:

Egm6341.s10.team1.lei 16:06, 17 February 2010 (UTC)

=Contributing members= EGM6341.s10.Team1.Kumanchik 19:34, 17 February 2010 (UTC) Author p17-1

Egm6341.s10.team1.toddmock 19:51, 17 February 2010 (UTC) Author p17-2(2 & 3)

Egm6341.s10.team1.andrewdugan 20:17, 17 February 2010 (UTC) Author p17-2(1)

Egm6341.s10.team1.lei 20:31, 17 February 2010 (UTC)

Egm6341.s10.team1.Ya-Chiao Chang 21:23, 17 February 2010 (UTC) Auhor p19-2