User:Egm6341.s10.Team4.yunseok/HW3

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

Given
Refer Lecture slide 17-3 18-1for problem statement

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

I = \int^{\pi}_{0} e^xcos(x)\; dx $$
 * $$\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

'''(1) 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 $$

'''(2) The Ratio of Error when $$\displaystyle n $$ is doubled,

'''(3) Asymptotic Estimates Ẽ

'''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

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

'''(2) 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) 

'''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) 

= about No. 5 =


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

T_o(2^{j})= \frac{b-a}{2^{j}} [ \frac{1}{2}f(x_0)+f(x_1)+f(x_2)+f(x_3)+f(x_4)+......+ \frac{1}{2} f(x_{2^{j}})] $$ For example
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.


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

T_0(64)= \frac{b-a}{64} [ \frac{1}{2}f(x_0)+f(x_1)+f(x_2)+f(x_3)+f(x_4)+......f(x_{63}) + \frac{1}{2} f(x_{64})] $$ the rear part can be arranged like that (decouple to the even number & odd number)
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.
 * {| style="width:100%" border="0" align="left"

T_0(64)= \frac{b-a}{64} [ \underbrace{\frac{1}{2}f(x_0)+f(x_2)+f(x_4)+... \frac{1}{2} f(x_{64})}_{even} ~ + \underbrace{f(x_1) +f(x_3)+f(x_5)+......f(x_{63})}_{odd}] $$ The even number part is exactly same with $$\displaystyle \frac{1}{2}T_0(32) $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.


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

\frac{b-a}{64}[ \frac{1}{2}f(x_0)+f(x_2)+f(x_4)+... \frac{1}{2} f(x_{64})] = \frac{1}{2} * \frac{b-a}{32}[ \frac{1}{2}f(x_0)+f(x_1)+f(x_2)+... \frac{1}{2} f(x_{32})] = \frac{1}{2}T_o(32)$$ So, the orginal $$\displaystyle T_0(64) $$ is like that
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.


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

T_0(64)= \frac{1}{2}T_o(32) + \frac{b-a}{64} [f(x_1) +f(x_3)+f(x_5)+......f(x_{63})] = \frac{1}{2}T_o(32) + \frac{b-a}{64} \sum_{i=1}^{32}f(x_{2i-1}) $$ if this is generalized,
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.


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

T_0(2^{j})= \frac{1}{2}T_o(2^{j-1})+ h \sum_{i=1}^{2^{j-1}}f(x_{2i-1}) $$ where
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.
 * {| style="width:100%" border="0" align="left"

h = \frac{b-a}{2^{j}} $$ In conclusion, if we know the $$\displaystyle T_0(2^{j-1}) $$, we can calculate more efficiently $$\displaystyle T_0(2^{j}) $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.

this is my understanding about problem 5..