User:Egm6341.s10.Team4.nimaa&m/HW2

= Problem 2: Proof of simple simpson's rule =

Given
Use equation (4) on slide [[media:Egm6341.s10.mtg8.pdf|8-3]], which is:
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle P_2(x_j)=\sum_{k=0}^2 l_i(x_j)f(x_i)=f(x_j)


 * }
 * }

Find
to derive equation (simple simpson's rule Use following Integration (2) on slide [[media:Egm6341.s10.mtg7.pdf|7-2]], which is:
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]              ;             h=\dfrac{b-a}{2}


 * }
 * }

Solution
The primary equation is following polynomial:



P_2(x)=\sum_{i=0}^2 l_i(x)f(x_i)=f_n(x) $$

From the lagrange equation we have:



l_i(x)=\prod_{i=1}^{N} \dfrac{x-x_j}{x_i-x_j} \Rightarrow l_0(x)=\dfrac{x-x_1}{x_0-x_1}\times\dfrac{x-x_2}{x_0-x_2} $$



\Rightarrow I_2=\int\limits_{x_0}^{x_2} P_2(x)\, dx=\int\limits_{x_0}^{x_2} \sum_{i=0}^2 l_i(x)f(x_i)\, dx=\int\limits_{x_0}^{x_2} [l_0(x)f(x_0)+l_1(x)f(x_1)+l_2(x)f(x_2)]\, dx $$

Similarly for other $$ l_i(x) $$ we can write:



l_1(x)=\dfrac{x-x_0}{x_1-x_0}\times\dfrac{x-x_2}{x_1-x_2} $$



l_2(x)=\dfrac{x-x_0}{x_2-x_0}\times\dfrac{x-x_1}{x_2-x_1} $$



\Rightarrow I_2=\int\limits_{x_0}^{x_2} [\dfrac{x-x_1}{x_0-x_1}\times\dfrac{x-x_2}{x_0-x_2}f(x_0)+\dfrac{x-x_0}{x_1-x_0}\times\dfrac{x-x_2}{x_1-x_2}f(x_1)+\dfrac{x-x_0}{x_2-x_0}\times\dfrac{x-x_1}{x_2-x_1}f(x_2)]\, dx $$



=\int\limits_{x_0}^{x_2} \dfrac{x-x_1}{x_0-x_1}\times\dfrac{x-x_2}{x_0-x_2}f(x_0)\, dx+\int\limits_{x_0}^{x_2} \dfrac{x-x_0}{x_1-x_0}\times\dfrac{x-x_2}{x_1-x_2}f(x_1)\, dx+\int\limits_{x_0}^{x_2} \dfrac{x-x_0}{x_2-x_0}\times\dfrac{x-x_1}{x_1-x_2}f(x_2)\, dx= $$



=\dfrac{f(x_0)}{(x_0-x_1)(x_0-x_2)}\int\limits_{x_0}^{x_2} (x^2-x_2x-x_1x+x_1x_2)\, dx+\dfrac{f(x_1)}{(x_1-x_0)(x_1-x_2)}\int\limits_{x_0}^{x_2} (x^2-x_2x-x_0x+x_0x_2)\, dx+\dfrac{f(x_2)}{(x_2-x_0)(x_2-x_1)}\int\limits_{x_0}^{x_2} (x^2-x_0x-x_1x+x_0x_1)\, dx= $$



=\dfrac{f(x_0)}{(x_0-x_1)(x_0-x_2)}[\dfrac{x^3}{3}-x_2\dfrac{x^2}{2}-x_1\dfrac{x^2}{2}+x_1x_2x]+\dfrac{f(x_1)}{(x_1-x_0)(x_1-x_2)}[\dfrac{x^3}{3}-x_2\dfrac{x^2}{2}-x_0\dfrac{x^2}{2}+x_0x_2x]+\dfrac{f(x_2)}{(x_2-x_0)(x_2-x_1)}[\dfrac{x^3}{3}-x_0\dfrac{x^2}{2}-x_1\dfrac{x^2}{2}+x_0x_1x] $$

If we name these three terms by u, v and w, respectively:



u=\dfrac{f(x_0)}{(x_0-x_1)(x_0-x_2)}[\dfrac{x_2^3}{3}-\dfrac{x_2^3}{2}-x_1\dfrac{x_2^2}{2}+x_1x_2^2-\dfrac{x_0^3}{3}+x_2\dfrac{x_0^2}{2}+x_1\dfrac{x_0^2}{2}-x_0x_1x_2] $$

Since,



x_0=a; x_1=\dfrac{a+b}{2}; x_2=b $$

And since,



(x_0-x_1)=-h;(x_0-x_2)=-2h; $$

We can rewrite the value of u as follows:



u=\dfrac{f(x_0)}{2h^2}[\dfrac{-b^3}{6}+(\dfrac{b+a}{4})b^2-\dfrac{a^3}{3}+\dfrac{a^2}{2}(\dfrac{3b+a}{2})-ab(\dfrac{b+a}{2})]= $$



u=\dfrac{f(x_0)}{2h^2}[\dfrac{b^3}{12}-\dfrac{a^3}{12}-\dfrac{ab^2}{4}+\dfrac{ba^2}{4}]=\dfrac{f(x_0)}{24h^2}(b^3-a^3-3ab^2+3ba^2)=\dfrac{f(x_0)}{24h^2}(b-a)^3=\dfrac{f(x_0)}{24h^2}\times(2h)^3=\dfrac{f(x_0)}{24h^2}\times8h^3 $$



\Rightarrow u=\dfrac{h\times f(x_0)}{3} $$

Similarly, for v and w we obtain:



v=\dfrac{f(x_1)}{-h^2}[\dfrac{-b^3}{6}+\dfrac{ab^2}{2}+\dfrac{a^3}{6}-\dfrac{ba^2}{2}]=\dfrac{f(x_1)}{6h^2}(b-a)^3=\dfrac{f(x_1)}{6h^2}(2h)^3=\dfrac{f(x_1)}{6h^2}8h^3 $$



\Rightarrow v=\dfrac{h\times 4f(x_1)}{3} $$



w=\dfrac{f(x_2)}{2h^2}[\dfrac{b^3}{3}-a\dfrac{b^2}{2}-\dfrac{a+b}{2}(\dfrac{b^2}{2})+a(\dfrac{a+b}{2})b-\dfrac{a^3}{3}+\dfrac{a^3}{2}+\dfrac{a+b}{2}(\dfrac{a^2}{2})-\dfrac{a+b}{2}a^2]= $$



w=\dfrac{f(x_2)}{2h^2}[\dfrac{b^3}{12}-\dfrac{a^3}{12}-\dfrac{ab^2}{4}+\dfrac{ba^2}{4}]=\dfrac{f(x_2)}{24h^2}(b^3-a^3-3ab^2+3ba^2)=\dfrac{f(x_0)}{24h^2}(b-a)^3=\dfrac{f(x_2)}{24h^2}\times(2h)^3=\dfrac{f(x_2)}{24h^2}\times8h^3 $$



\Rightarrow u=\dfrac{h\times f(x_2)}{3} $$

Eventually, by adding u, v and w, we gain the entire equation:


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

$$ I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)] $$
 * style="width:30%; padding:10px; border:1px solid #8888aa" |
 * style="width:30%; padding:10px; border:1px solid #8888aa" |
 * style= |
 * }

= Problem 4: From simple Trap. rule and simple Simpson's rule to the composite types =

Given
The simple Trapezoidal rule equation is written as follows:
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle I_1=\dfrac{b-a}{2}[f(a)+f(b)]
 * $$\displaystyle I_1=\dfrac{b-a}{2}[f(a)+f(b)]

Also, the simple Simpson's rule equation is written as: $$
 * $$\displaystyle I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]
 * $$\displaystyle I_2=\dfrac{h}{3}[f(x_0)+4f(x_1)+f(x_2)]


 * }
 * }

Find
Show that from these two simple forms of equations we can develop composite forms of them respectively, as below:
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle I_n=h[\dfrac{1}{2}f_0+f_1+...+\dfrac{1}{2}f_{n-1}]
 * $$\displaystyle I_n=h[\dfrac{1}{2}f_0+f_1+...+\dfrac{1}{2}f_{n-1}]

$$
 * $$\displaystyle I_n=\dfrac{h}{3}[f_0+4f_1+2f_2+4f_3+2f_4+...+2f_{n-2}+4f_{n-1}+f_n]
 * $$\displaystyle I_n=\dfrac{h}{3}[f_0+4f_1+2f_2+4f_3+2f_4+...+2f_{n-2}+4f_{n-1}+f_n]


 * }
 * }

Solution
Part 1: For Trapezoidal rule, for one interval (n=1) and h equal to width of the interval (a is start point and b is the end point), we have:



I_1=\dfrac{x_1-x_0}{2}(f(x_0)+f(x_1)) $$

When we take two intervals (n=2) and h equal to width of each interval:



I_2=\dfrac{x_1-x_0}{2}(f(x_0)+f(x_1))+\dfrac{x_2-x_1}{2}(f(x_1)+f(x_2)) $$



\Rightarrow I_2=\dfrac{h}{2}(f(x_0)+2f(x_1)+f(x_2)) $$

By continuing this procedure for 4 intervals, we gain:



I_4=\dfrac{x_1-x_0}{2}(f(x_0)+f(x_1))+\dfrac{x_2-x_1}{2}(f(x_1)+f(x_2))+\dfrac{x_3-x_2}{2}(f(x_2)+f(x_3))+\dfrac{x_4-x_3}{2}(f(x_3)+f(x_4)) $$



\Rightarrow I_4=\dfrac{h}{2}(f(x_0)+2f(x_1)+2f(x_2)+2f(x_3)+f(x_4)) $$

Thus, when n intervals are selected, this procedure can be resulted in:



\Rightarrow I_n=h(\dfrac{1}{2}f(x_0)+f(x_1)+f(x_2)+...+f(x_{n-1})+\dfrac{1}{2}f(x_{n})) $$

Part 2: Similarly, when we have 2 intervals for Simpson's rule (trivially h is the width of each one), we can write following from the simple case:



I_2=\dfrac{h}{3}(f(x_0)+4f(x_1)+f(x_2)) $$

For 4 intervals, we can extend the above equation to:



I_4=\dfrac{h}{3}(f(x_0)+4f(x_1)+f(x_2))+\dfrac{h}{3}(f(x_2)+4f(x_3)+f(x_4)) $$



\Rightarrow I_4=\dfrac{h}{3}(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+f(x_4)) $$

For 6 intervals, we can extend the above equation to:



I_6=\dfrac{h}{3}(f(x_0)+4f(x_1)+f(x_2))+\dfrac{h}{3}(f(x_2)+4f(x_3)+f(x_4))+\dfrac{h}{3}(f(x_4)+4f(x_5)+f(x_6)) $$



\Rightarrow I_6=\dfrac{h}{3}(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+4f(x_5)+f(x_6)) $$

Thus, when n intervals are selected, this pattern can be translated in:



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

= Problem 8 =

Given
Let function $$\displaystyle f(x)$$ and $$\displaystyle t=2, x_0=3, x_1=4, ..., x_6=9$$


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

$$ $$
 * $$\displaystyle f(x)=log(x)
 * $$\displaystyle f(x)=log(x)
 * $$\displaystyle


 * }
 * }

Find
Plot 3 figures similar to plotted graphs on slide [[media:Egm6341.s10.mtg11.pdf|11-2]] showing following functions,

$$\displaystyle f(x), f_n(x), l_{i,n}(x), q_{n+1}(x)$$

for $$\displaystyle i=3 (x_3=6)$$ and $$\displaystyle x=5.5$$

Solution
The primary function f(x) and estimated function by Newton-Cotes formula will be defined as:


 * $$\displaystyle

f(x)=log(x) $$



f_n(x)=\sum_{i=0}^6 l_{i,n}(x)f(x_i)=\sum_{i=0}^6 l_{i,n}(x)log(x_i) $$

Where the Lagrange equation is introduced with below equation for i=3:



l_{i,n}(x)=\prod_{i=1}^{n} \dfrac{x-x_j}{x_i-x_j} \Rightarrow l_{3,6}(x)=\dfrac{x-x_0}{x_3-x_0}\times\dfrac{x-x_1}{x_3-x_1}\times\dfrac{x-x_2}{x_3-x_2}\times\dfrac{x-x_4}{x_3-x_4}\times\dfrac{x-x_5}{x_3-x_5}\times\dfrac{x-x_6}{x_3-x_6} $$


 * $$\displaystyle

q_{n+1}(t)=(t-x_0)(t-x_1)(t-x_2)...(t-x_n) $$

Constructing these fucntions by the Matlab codes, facilitate us to attain following graphs:

Ultimately, the error of interpolation error theorem can be attained as following for this problems for at t=2 and x=5.5 by n=1000.

$$ \begin{array}{|c||c|c|} x & q_{n+1}(t) & f(t) - f_n(t) \\ \hline t=2&-5040&0.003887\\ x=5.5&12.30469&-4.1086E^{-6}\\ \hline \end{array} $$

 Matlab Code: 

= Problem 9: Proof of error for simple trapezoidal rule =

Given
Refer to Lecture slide 13-2 for problem statement
 * {| style="width:100%" border="0" align="left"

\begin{align} n=1, \\ & q_2(x)=(x-x_o)(x-x_1)\\ & x_o=a, x_1=b, \end{align} $$
 * $$\displaystyle
 * $$\displaystyle


 * }.
 * }.

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

\left | E_1 \right | = \frac{M_2}{2!}\int_{a}^{b}\left|q_2(x) \right |\, dx = \frac{M_2}{2!}\int_{a}^{b}\left|(x-x_o)(x-x_1) \right |\frac{(b-a)^3}{12}M_2 $$
 * $$\displaystyle
 * $$\displaystyle


 * }.
 * }.

Solution

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

\begin{align} \dfrac {M_2}{2!}\int\limits_{a}^{b} (x-a)(b-x)\, dx=\dfrac{M_2}{2!}\int\limits_{a}^{b} (bx-x^2-ab+ax)\, dx=\dfrac{M_2}{2!}[\dfrac{bx^2}{2}-\dfrac{x^3}{3}-abx+\dfrac{ax^2}{2}]\, \Big |^b_a\\ \end{align} $$
 * $$\displaystyle
 * $$\displaystyle
 * }.
 * }.



\dfrac{M_2}{2!}[\dfrac{b^3}{2}-\dfrac{b^3}{3}-ab^2+\dfrac{ab^2}{2}-\dfrac{ba^2}{2}+\dfrac{a^3}{3}+a^2b-\dfrac{a^3}{2}]=\dfrac{M_2}{2!}[\dfrac{b^3}{6}-\dfrac{a^3}{6}-\dfrac{ab^2}{2}+\dfrac{a^2b}{2}]=\dfrac{M_2}{12}[b^3-a^3-3ab^2+3a^2b]=\dfrac{M_2}{12}(b-a)^3=\dfrac{M^2}{12}h^3 $$


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

$$ \Rightarrow \left | E_1 \right | = \frac{M_2}{2!}\int_{a}^{b}\left|q_2(x) \right |\, dx=\dfrac{M^2}{12}h^3 $$
 * style="width:10%; padding:10px; border:1px solid #8888aa" |
 * style="width:10%; padding:10px; border:1px solid #8888aa" |
 * style= |
 * }

= Problem 14: Third derivative of e(t) in Lagrange Intp. Error =

Given
If we define function e(t) as the following,
 * {| style="width:100%" border="0" align="left"

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle e(t)=\int\limits_{-t}^{t} F(t)\, dt-\dfrac{t}{3}[F(-t)+4F(0)+F(t)]


 * }
 * }

Find
Show that:


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

$$ $$
 * $$\displaystyle
 * $$\displaystyle
 * $$\displaystyle e^{(3)}(t)=\dfrac{-t}{3}[F^{(3)}(t)-F^{(3)}(-t)]


 * }
 * }

Solution
Let e(t) is the summation of these two terms:


 * $$\displaystyle

e(t)=\alpha(t)-\alpha_2(t) $$

Basically, we have the following in the calculus for differentiating an integral:



({\int\limits_{g(x)}^{h(x)} f(x)\, dx})'=\dfrac{d}{dx}\int\limits_{g(x)}^{h(x)} f(x)\, dx=f(h(x)).h'(x)-f(g(x)).g'(x) $$ Assuming k a point in the [-t,t] interval:



\alpha (t)=\int\limits_{-t}^{k} F(t)\, dt+\int\limits_{k}^{t} F(t)\, dt $$



\Rightarrow \alpha^{(1)}(t)=[F(k)\times0-F(-t)\times(-1)]+[F(t)\times 1-F(k)\times 0]=F(-t)+F(t) $$



\Rightarrow \alpha^{(2)}(t)=[F^{(1)}(-t)\times(-1)+F^{(1)}(t)\times 1]=F^{(1)}(t)-F^{(1)}(-t) $$



\Rightarrow \alpha^{(3)}(t)=F^{(2)}(t)+F^{(2)}(-t) $$



\alpha_2^{(1)}(t)=\dfrac{1}{3}[F(-t)+4F(0)+F(t)]-\dfrac{t}{3}F^{(1)}(-t)+0+\dfrac{t}{3}F^{(1)}(t) $$



\Rightarrow \alpha_2^{(2)}(t)=-\dfrac{1}{3}F^{(1)}(-t)+\dfrac{1}{3}F^{(1)}(t)-\dfrac{1}{3}F^{(1)}(-t)+\dfrac{t}{3}F^{(2)}(-t)+\dfrac{1}{3}F^{(1)}(t)+\dfrac{t}{3}F^{(2)}(t) $$



=-\dfrac{2}{3}F^{(1)}(-t)+\dfrac{2}{3}F^{(1)}(t)+\dfrac{t}{3}F^{(2)}(-t)+\dfrac{t}{3}F^{(2)}(t) $$



\Rightarrow \alpha_2^{(3)}(t)=\dfrac{2}{3}F^{(2)}(-t)+\dfrac{2}{3}F^{(2)}(t)+\dfrac{1}{3}F^{(2)}(-t)-\dfrac{t}{3}F^{(3)}(-t)+\dfrac{1}{3}F^{(2)}(t)+\dfrac{t}{3}F^{(3)}(t) $$



=F^{(2)}(-t)+F^{(2)}(t)+\dfrac{t}{3}[F^{(3)}(t)-F^{(3)}(-t)] $$



\Rightarrow e^{(3)}(t)=\alpha^{(3)}(t)-\alpha_2^{(3)}(t)=F^{(2)}(t)+F^{(2)}(-t)-F^{(2)}(-t)-F^{(2)}(t)+\dfrac{t}{3}[F^{(3)}(-t)-F^{(3)}(t)]= $$



=\dfrac{t}{3}[F^{(3)}(-t)-F^{(3)}(t)]=\dfrac{-t}{3}[F^{(3)}(t)-F^{(3)}(-t)] $$


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

$$ e^{(3)}(t)=\dfrac{-t}{3}[F^{(3)}(t)-F^{(3)}(-t)] $$
 * style="width:30%; padding:10px; border:1px solid #8888aa" |
 * style="width:30%; padding:10px; border:1px solid #8888aa" |
 * style= |
 * }