User:Egm6341.s10.team3.heejun/HW2

= (5) Find n with Taylor=

Problem Statement
Find n at $$ \displaystyle \left|{f}_{n}^{T}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| \leq \left|{f}_{4}^{L}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| \leq \left| \frac{{q}_{5}(t)}{5!} \right| $$  for  $$ \displaystyle f(x) = sin(x) $$ and $$ \displaystyle x_{0} = 0, x_{1} = \frac{\pi}{4}, x_{2} = \frac{\pi}{2}, x_{3} = \frac{3\pi}{4}, x_{4} = 1 $$. Ref: Lecture Notes [[media:Egm6341.s10.mtg11.pdf|p.11-1]]

Solution
Matlab codes for this problem is provided later.

First, construct Lagrange interpolating function $$ f_{4}^{L}(x) $$ and polynomial $$\displaystyle q_{5}(x) $$.


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

f_{4}^{L}(x)=P_{4}(x)= \sum_{i=0}^{4}l_{i,4}(x)f(x_{i}) $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle (Eq. 1)
 * }
 * }

where


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

l_{i,4}(x)=\Pi_{j=0, j \neq 4}^{4}\frac{x-x_{j}}{x_{i}-x_{j}} $$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle (Eq. 2)
 * }
 * }

Then, compare the constructed function $$\displaystyle f_{4}^{L}(x)$$ with the original function $$\displaystyle f(x)=sin(x)$$ by plotting them in the same figure.

Now, to check the fact $$\displaystyle \left|{f}_{4}^{L}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| \leq \left| \frac{{q}_{5}(t)}{5!} \right| $$, compute $$\displaystyle f_{4}^{L}(\frac{7\pi}{8})$$, $$\displaystyle f(\frac{7\pi}{8})$$ and $$\displaystyle \frac{\left|q_{5}(\frac{7\pi}{8})\right|}{5!}$$.


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

f_{4}^{L}(\frac{7\pi}{8}) = 3.812026433338313e-001 $$
 * $$\displaystyle
 * $$\displaystyle
 * }
 * {| style="width:100%" border="0" align="left"
 * {| style="width:100%" border="0" align="left"

f(\frac{7\pi}{8}) = sin(\frac{7\pi}{8}) = 3.826834260893118e-001 $$
 * $$\displaystyle
 * $$\displaystyle
 * }
 * {| style="width:100%" border="0" align="left"
 * {| style="width:100%" border="0" align="left"

\frac{\left|q_{5}(\frac{7\pi}{8})\right|}{5!} = 8.171616062246945e-003 $$
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }

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

\left|E_{4}^{L}(\frac{7\pi}{8})\right|=\left|{f}_{4}^{L}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| \leq \left| \frac{{q}_{5}(t)}{5!} \right| $$
 * $$\displaystyle
 * $$\displaystyle
 * }
 * }


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

$$\displaystyle \Rightarrow \left|E_{4}^{L}(\frac{7\pi}{8})\right| = 1.480782755480525e-003 \leq \frac{\left|q_{5}(\frac{7\pi}{8})\right|}{5!} = 8.171616062246945e-003 $$
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }

 Matlab code for above plot and calculations 

Now, calculate $$ \displaystyle \left|{f}_{n}^{T}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| \leq 1.480782755480525e-003 $$ when $$ \displaystyle n=0, 1, 2, 3... n $$

Taylor Expansion of $$ \displaystyle f(x)=sin(x) $$ at $$ \displaystyle x_0 = \frac{\pi}{4} $$ Ref: Homework No. 1 [|Question 7]

a) Case 1 ($$\displaystyle n=0 $$) $$ \left|{f}_{0}^{T}(x) - f(x)\right| = \left| sin(x) - sin(x)\right| = 0 $$

b) Case 2 ($$\displaystyle n=1 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!}\Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!}\Bigg] -sin(\frac{7\pi}{8}) \right| = 1.712824266995947 $$

c) Case 3 ($$\displaystyle n=2 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.349764853003978 $$

d) Case 4 ($$\displaystyle n=3 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.542355447288433 $$

e) Case 5 ($$\displaystyle n=4 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) + {f}_{4}^{T}(x)- f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} + \frac{(x-\frac{\pi}{4})^4}{4!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^4}{4!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.104436918926408 $$

f) Case 6 ($$\displaystyle n=5 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) + {f}_{4}^{T}(x)+ {f}_{5}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} + \frac{(x-\frac{\pi}{4})^4}{4!} + \frac{(x-\frac{\pi}{4})^5}{5!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^4}{4!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^5}{5!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.067533285020216 $$

g) Case 7 ($$\displaystyle n=6 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) + {f}_{4}^{T}(x) + {f}_{5}^{T}(x) + {f}_{6}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} + \frac{(x-\frac{\pi}{4})^4}{4!} + \frac{(x-\frac{\pi}{4})^5}{5!} - \frac{(x-\frac{\pi}{4})^6}{6!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^4}{4!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^5}{5!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^6}{6!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.011256167379064 $$

h) Case 8 ($$\displaystyle n=7 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) + {f}_{4}^{T}(x) + {f}_{5}^{T}(x) + {f}_{6}^{T}(x) + {f}_{7}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} + \frac{(x-\frac{\pi}{4})^4}{4!} + \frac{(x-\frac{\pi}{4})^5}{5!} - \frac{(x-\frac{\pi}{4})^6}{6!} - \frac{(x-\frac{\pi}{4})^7}{7!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^4}{4!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^5}{5!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^6}{6!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^7}{7!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 0.004529527205458 $$

i) Case 9 ($$\displaystyle n=8 $$) $$ \left|{f}_{0}^{T}(x) + {f}_{1}^{T}(x) + {f}_{2}^{T}(x) + {f}_{3}^{T}(x) + {f}_{4}^{T}(x) + {f}_{5}^{T}(x) + {f}_{6}^{T}(x) + {f}_{7}^{T}(x) + {f}_{8}^{T}(x) - f(x)\right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!} - \frac{(x-\frac{\pi}{4})^3}{3!} + \frac{(x-\frac{\pi}{4})^4}{4!} + \frac{(x-\frac{\pi}{4})^5}{5!} - \frac{(x-\frac{\pi}{4})^6}{6!} - \frac{(x-\frac{\pi}{4})^7}{7!} + \frac{(x-\frac{\pi}{4})^8}{8!} \Bigg] - sin(x) \right| $$ $$ = \left| \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})}{1!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^2}{2!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^3}{3!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^4}{4!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^5}{5!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^6}{6!} - \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^7}{7!} + \frac{(\frac{7\pi}{8}-\frac{\pi}{4})^8}{8!} \Bigg] -sin(\frac{7\pi}{8}) \right| = 6.551348508838095*10^{-4} $$

Compare with the value of $$ \left|{f}_{4}^{L}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| $$

Thus, $$ \left|{f}_{n}^{T}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| $$ is smaller than $$ \left|{f}_{4}^{L}(\frac{7\pi}{8}) - f(\frac{7\pi}{8})\right| $$ when n=8.

= (9) Verify E1=

Problem Statement
Show that $$ \left| {E}_{1}\right| \leq \frac{M_{2}}{2!}\int_{a}^{b}\left | q_{2}(x) \right | dx = \frac{{M}_{2}}{2!}\int_{a}^{b}(x-a)(b-x) dx = \frac{{(b-a)}^{3}}{12}{M}_{2} = \frac{h^{3}}{12}M_{2} $$ where $$ \displaystyle h:= b-a $$ Ref: Lecture Notes [[media:Egm6341.s10.mtg13.pdf|p.13-2]]

Solution
Expansion $$ \displaystyle (x-a)(b-x) $$ $$ \frac{{M}_{2}}{2!}\int_{a}^{b}(x-a)(b-x) dx = -\frac{{M}_{2}}{2!}\int_{a}^{b}\left \{ x^{2}-(a+b)x+ab \right \}dx $$

Integrating $$ \displaystyle \left \{ x^{2}-(a+b)x+ab \right \} $$ $$ = -\frac{{M}_{2}}{2!}\left [ \left \{ \frac{1}{3}b^{3}-\frac{1}{2}(a+b)b^{2}+ab^{2} \right \}-\left \{ \frac{1}{3}a^{3}-\frac{1}{2}(a+b)a^{2}+a^{2}b \right \} \right ] $$ $$ = -\frac{{M}_{2}}{2!6}(-b^{3}+3ab^{2}-3a^{2}b+a^{3}) $$ $$ = \frac{{M}_{2}}{2!6}(b^{3}-3ab^{2}+3a^{2}b-a^{3}) $$ $$ = \frac{M_{2}}{12}\underbrace {(b-a)^{3}}_{by Binomial Theorem} $$

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

$$\displaystyle \left| {E}_{1}\right| \leq \frac{M_{2}}{2!}\int_{a}^{b}\left | q_{2}(x) \right | dx = \frac{{M}_{2}}{2!}\int_{a}^{b}(x-a)(b-x) dx = \frac{{(b-a)}^{3}}{12}{M}_{2} = \frac{h^{3}}{12}M_{2} $$
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }

= (10) Verify E2=

Problem Statement
Show that $$ \left| {E}_{n}\right| \leq \frac{{M}_{3}}{3!}\int_{a}^{b}\left|(x-a)(x-\frac{a+b}{2})(x-b) \right| dx = \frac{{(b-a)}^{4}}{196}{M}_{3} = \frac{{2}^{4}{h}^{4}}{196}{M}_{3} $$ where $$ h:=\frac{b-a}{2} \Rightarrow b-a = 2h $$ Ref: Lecture Notes [[media:Egm6341.s10.mtg13.pdf|p.13-2]]

Solution
Determination the range at $$ \displaystyle {(x-a)(x-\frac{(a+b)}{2})(b-x)} $$ always $$ \displaystyle \geq 0 $$ $$ \frac{{M}_{3}}{3!}\int_{a}^{b} \left|(x-a)(x-\frac{(a+b)}{2})(x-b) \right| dx $$ $$ = \frac{{M}_{3}}{3!}\left[\underbrace {\int_{a}^{\frac{(a+b)}{2}}(x-a)(x-\frac{(a+b)}{2})(x-b)dx}_{call {P}_{1}} - \underbrace {\int_{\frac{(a+b)}{2}}^{b}(x-a)(x-\frac{(a+b)}{2})(x-b)dx}_{call {P}_{2}}\right] $$

Integrating $$ \displaystyle P_{1} $$ $$ \int_{a}^{\frac{(a+b)}{2}}(x-a)(x-\frac{(a+b)}{2})(x-b)dx $$ $$ = \frac{1}{4}(\frac{a+b}{2})(\frac{-a-b}{2})(\frac{{a}^{2}+2ab+{b}^{2}}{4}-\frac{{a}^{2}+2ab+{b}^{2}}{2}+2ab)-\frac{1}{4}a(-b)({a}^{2}-{a}^{2}-ab+2ab) $$ $$ = -\frac{1}{4}\times\frac{{(a+b)}^{2}}{4}\times \frac{{-(a-b)}^{2}+4ab}{4}+\frac{{a}^{2}{b}^{2}}{4} $$ $$ = -\frac{1}{{4}^{3}} {(a+b)}^{2} \left[ 4ab-{(a-b)}^{2} \right] +\frac{{a}^{2}{b}^{2}}{4} $$

Integrating $$ \displaystyle P_{2} $$ $$ \int_{\frac{(a+b)}{2}}^{b}(x-a)(x-\frac{(a+b)}{2})(x-b)dx $$ $$ = -\frac{{a}^{2}{b}^{2}}{4} + \frac{1}{{4}^{3}}{(a+b)}^{2}\left[ 4ab-{(a-b)}^{2} \right] $$

Computing $$ \displaystyle P_{1}-P_{2} $$ $$ \begin{align} P_{1}-P_{2} &= \frac{a^{2}b^{2}}{2}+\frac{(a+b)^{2}}{4^{3}}\left [ 2(a-b)^{2}-8ab \right ] \\ &=\frac{1}{32} \left [ (a^{4}+b^{4})-4ab(a^{2}+b^{2})+6a^{2}b^{2} \right ] \\ &=\frac{1}{32} \underbrace{(a^{4}-4a^{3}b+6a^{2}b^{2}-4ab^{3}+b^{4})}_{by Binomial Thereom}\\ &=\frac{(a-b)^{4}}{32} = \frac{(b-a)^{4}}{32}\\\end{align}\ $$

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

$$\displaystyle \displaystyle I=\frac{M_{3}}{3!}(P_{1}-P_{2}) = \frac{M_{3}}{3!} \frac{(b-a)^{4}}{32} = \frac{M_{3}}{192}(b-a)^{4} $$
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }

= (15) Relationship between $$ \xi $$ and $$ \zeta_{4} $$=

Problem Statement
$$ -\frac{1}{90}F^{(4)}(\zeta _{4})=-\frac{(b-a)^{4}}{1440}f^{4}(\xi) $$

Ref: Lecture Notes [[media:Egm6341.s10.mtg15.pdf|p.15-3]]

Solution
Use chain Rule $$ \displaystyle F(t)=f(x) $$ $$ \displaystyle x(t)=x_{1}+ht $$ $$ \displaystyle F^{(1)}(t)=\frac{dF(t)}{dt} = \frac{df(x)}{dx}\frac{dx}{dt} = f^{(1)}(x) \times h = hf^{(1)}(x) $$ $$ \because \frac{d\left(x(t)\right)}{dt} = \frac{d(x_{1}+ht)}{dt} = h $$ $$ \displaystyle F^{(2)}(t) = \frac{d\left(F(t)^{(1)}\right)}{dt} = \frac{d\left(hf(x)^{(1)}\right)}{dx}\frac{dx}{dt} = hf^{(2)}(x) \times h = h^{2}f^{(1)}(x) $$ $$ \displaystyle F^{(3)}(t) = \frac{d\left(F(t)^{(2)}\right)}{dt} = \frac{d\left(h^{2}f(x)^{(2)}\right)}{dx}\frac{dx}{dt} = h^{2}f^{(3)}(x) \times h = h^{3}f^{(3)}(x) $$ $$ \displaystyle F^{(4)}(t) = \frac{d\left(F(t)^{(3)}\right)}{dt} = \frac{d\left(h^{3}f(x)^{(3)}\right)}{dx}\frac{dx}{dt} = h^{3}f^{(4)}(x) \times h = h^{4}f^{(4)}(x) $$

Now, obtain the relationship between $$ \displaystyle \xi $$ and $$ \displaystyle \zeta_{4} $$ $$ \displaystyle x(\zeta_{4}) = x_{1} + h\zeta_{4} = \xi $$

And recall that $$ \displaystyle h=\frac{b-a}{2} $$ Then,

$$ \displaystyle -\frac{1}{90}F^{(4)}(\zeta _{4})=-\frac{1}{90}\left(h^{4}f^{(4)}(\xi)\right)=-\frac{1}{90}\left(\frac{(b-a)^{4}}{2^{4}}f^{(4)}(\xi)\right) $$

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

$$\displaystyle -\frac{1}{90}F^{(4)}(\zeta _{4})=-\frac{(b-a)^{4}}{1440}f^{4}(\xi) $$ where
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$\displaystyle \xi = x_{1}+h \zeta_{4} $$ --Heejun Chung 15:43, 10 February 2010 (UTC)
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }