User:Egm6341.s10.team3.sa

Om Sri Guru Raghavendra

HW1 HW2 HW3 HW4 HW1-Updated HW2-Updated HW5 HW5-Updated HW6 HW7 

Mtg1

= (1) Plotting a given function $$ f(x) $$ = Ref: Lecture Notes [[media:Egm6341.s10.mtg2.pdf|p.2-2]]

Problem Statement
$$f(x) = \frac{e^x -1}{x} x \in [0,1] $$ (i) Find $$ \lim_{x\rightarrow 0} f(x)$$ (ii)Plot $$ \displaystyle f(x) $$

Solution
(i) By L'Hospital's rule,
 * {| style="width:100%" border="0" align="left"


 * $$\lim_{x\rightarrow 0} f(x) = \lim_{x\rightarrow 0} \frac{e^x -1}{x}$$
 * }
 * }
 * }


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


 * $$ = \lim_{x\rightarrow 0} \frac {\frac{d}{dx}(e^x -1)} {\frac {d}{dx}(x)}$$
 * }
 * }
 * }


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


 * $$ = \lim_{x\rightarrow 0} {e^x}$$
 * }
 * }
 * }


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


 * $$\displaystyle =1 $$
 * }
 * }
 * }

(ii) MATLAB Code to generate the plot

Plot :  $$\frac {e^x -1}{x}$$ vs $$ \displaystyle x $$

= (7) Expressing a function $$ f(.)$$ using Taylor Series = Ref: Lecture Notes [[media:Egm6341.s10.mtg6.pdf|p.6-1]]

Problem Statement
$$ f(x)=sin x, x \in [0,\pi] $$ (i)Construct a Taylor series of $$f(x)$$ around $$x_0 = \frac{\pi}{4}$$ for $$\displaystyle n=0,1,2......,10.$$ (ii)Plot the series for each $$\displaystyle n $$ (iii)Estimate the maximum $$\displaystyle R(x)$$ at $$ x=\frac{\pi}{2}$$

Solution
(i) $$\displaystyle n^{th}$$ order polynomial is given by, $$\displaystyle P_n(x) = f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + ........+ \frac{(x-x_0)^n}{n!}f^n(x_0) $$

(a)$$\displaystyle P_n(x)$$ for $$\displaystyle n=0 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$


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


 * $$ \displaystyle P_0(x)= f(x_0) $$
 * }
 * }
 * }


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

$$\displaystyle P_0(x) = sin (\frac{\pi}{4}) = \frac{1}{\sqrt{2}}$$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(b)$$\displaystyle P_n(x)$$ for $$\displaystyle n=1 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_1(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) $$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_1(x)= \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!}\Bigg] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(c)$$\displaystyle P_n(x)$$ for $$\displaystyle n=2 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_2(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) $$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4})$$
 * }
 * }


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

$$ \displaystyle P_2(x)= \frac{1}{\sqrt{2}}\Bigg[1 + \frac{(x-\frac{\pi}{4})}{1!} - \frac{(x-\frac{\pi}{4})^2}{2!}\Bigg] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(d)$$\displaystyle P_n(x)$$ for $$\displaystyle n=3 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_3(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0)$$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_3(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(e)$$\displaystyle P_n(x)$$ for $$\displaystyle n=4 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_4(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) $$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_4(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(f)$$\displaystyle P_n(x)$$ for $$\displaystyle n=5 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_5(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0)$$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_5(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(g)$$\displaystyle P_n(x)$$ for $$\displaystyle n=6 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"


 * $$ \displaystyle P_6(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0)$$
 * }
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^6}{6!} sin(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_6(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(h)$$\displaystyle P_n(x)$$ for $$\displaystyle n=7 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"

$$ \displaystyle + \frac{(x-x_0)^7}{7!} f^7(x_0)$$
 * $$ \displaystyle P_7(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * $$ \displaystyle P_7(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^6}{6!} sin(\frac{\pi}{4})$$ $$\displaystyle -\frac{(x-\frac{\pi}{4})^7}{7!} cos(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_7(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(i)$$\displaystyle P_n(x)$$ for $$\displaystyle n=8 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"

$$ \displaystyle + \frac{(x-x_0)^7}{7!} f^7(x_0) + \frac{(x-x_0)^8}{8!} f^8(x_0)$$
 * $$ \displaystyle P_8(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * $$ \displaystyle P_8(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^6}{6!} sin(\frac{\pi}{4})$$ $$\displaystyle -\frac{(x-\frac{\pi}{4})^7}{7!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^8}{8!} sin(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_8(x)= \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] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(j)$$\displaystyle P_n(x)$$ for $$\displaystyle n=9 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"

$$ \displaystyle + \frac{(x-x_0)^7}{7!} f^7(x_0) + \frac{(x-x_0)^8}{8!} f^8(x_0) + \frac{(x-x_0)^9}{9!} f^9(x_0)$$
 * $$ \displaystyle P_9(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * $$ \displaystyle P_9(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^6}{6!} sin(\frac{\pi}{4})$$ $$\displaystyle -\frac{(x-\frac{\pi}{4})^7}{7!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^8}{8!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^9}{9!} cos(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_9(x)= \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!} + \frac{(x-\frac{\pi}{4})^9}{9!} \Bigg] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(k)$$\displaystyle P_n(x)$$ for $$\displaystyle n=10 $$ and $$\displaystyle x_0 = \frac{\pi}{4}$$
 * {| style="width:100%" border="0" align="left"

$$ \displaystyle + \frac{(x-x_0)^7}{7!} f^7(x_0) + \frac{(x-x_0)^8}{8!} f^8(x_0) + \frac{(x-x_0)^9}{9!} f^9(x_0) + \frac{(x-x_0)^{10}}{10!} f^{10}(x_0)$$
 * $$ \displaystyle P_{10}(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * $$ \displaystyle P_{10}(x)= f(x_0) + \frac{(x-x_0)}{1!} f^1(x_0) + \frac{(x-x_0)^2}{2!} f^2(x_0) + \frac{(x-x_0)^3}{3!} f^3(x_0) +  \frac{(x-x_0)^4}{4!} f^4(x_0) + \frac{(x-x_0)^5}{5!} f^5(x_0) + \frac{(x-x_0)^6}{6!} f^6(x_0) $$
 * }
 * }


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

$$ \displaystyle = sin (\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})}{1!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^2}{2!} sin(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^3}{3!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^4}{4!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^5}{5!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^6}{6!} sin(\frac{\pi}{4})$$ $$\displaystyle -\frac{(x-\frac{\pi}{4})^7}{7!} cos(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^8}{8!} sin(\frac{\pi}{4}) + \frac{(x-\frac{\pi}{4})^9}{9!} cos(\frac{\pi}{4}) - \frac{(x-\frac{\pi}{4})^{10}}{10!} sin(\frac{\pi}{4}) $$
 * }
 * }


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

$$ \displaystyle P_{10}(x)= \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!} + \frac{(x-\frac{\pi}{4})^9}{9!} - \frac{(x-\frac{\pi}{4})^{10}}{10!}\Bigg] $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(ii) MATLAB Code for generating the plots for :     $$ \displaystyle n=0,1......,10 $$

Plot: $$\displaystyle f(x)=sin(x)$$ for $$\displaystyle n = 0, 1, 2, 3, 4 and 5$$

$$\displaystyle f(x)=sin(x)$$ for $$\displaystyle n = 6, 7, 8, 9 and 10$$



(iii)Error Estimation $$\displaystyle R_{n+1}(x) = \frac{(x-x_0)^{n+1}}{(n+1)!} f^{n+1}(\xi)$$ $$\displaystyle max R_{n+1}(x) = \frac{(x-x_0)^{n+1}}{(n+1)!} max \bigg| f^{n+1}(\xi)\bigg|$$

Since $$\displaystyle f(x) = sin (x)$$  $$\displaystyle max \bigg| f^{n+1}(\xi)\bigg| = 1  $$ for all $$\displaystyle n $$

(a)$$\displaystyle R_{n+1}(x)$$ for $$\displaystyle n=0 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{n+1}(x)_{max}= \frac{x-x_0}{1!} $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{\frac{\pi}{2}-\frac{\pi}{4}}{1!} $$
 * }
 * }


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

$$\displaystyle R_1(x)_{max} = 0.6168 $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(b)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=1 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{2}(x)_{max}= \frac{(x-x_0)^2}{2!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^2}{2!} $$
 * }
 * }


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

$$\displaystyle R_2(x)_{max} = 0.3084 $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(c)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=2 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{3}(x)_{max}= \frac{(x-x_0)^3}{3!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^3}{3!} $$
 * }
 * }


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

$$\displaystyle R_3(x)_{max} = 0.0807 $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(d)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=3 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{4}(x)_{max}= \frac{(x-x_0)^4}{4!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^4}{4!} $$
 * }
 * }


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

$$\displaystyle R_4(x)_{max} = 0.0158 $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(e)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=4 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{5}(x)_{max}= \frac{(x-x_0)^5}{5!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^5}{5!} $$
 * }
 * }


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

$$\displaystyle R_5(x)_{max} = 2.4903 * 10^{-3} $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(f)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=5 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{6}(x)_{max}= \frac{(x-x_0)^6}{6!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^6}{6!} $$
 * }
 * }


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

$$\displaystyle R_6(x)_{max} = 3.2599 * 10^{-4}$$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(g)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=6 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{7}(x)_{max}= \frac{(x-x_0)^7}{7!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^7}{7!} $$
 * }
 * }


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

$$\displaystyle R_7(x)_{max} = 3.6576 * 10^{-5} $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(h)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=7 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{8}(x)_{max}= \frac{(x-x_0)^8}{8!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^8}{8!} $$
 * }
 * }


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

$$\displaystyle R_8(x)_{max} = 3.5908 * 10^{-6} $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(i)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=8 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{9}(x)_{max}= \frac{(x-x_0)^9}{9!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^9}{9!} $$
 * }
 * }


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

$$\displaystyle R_9(x)_{max} = 3.1336 * 10^{-7}$$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(j)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=9 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{10}(x)_{max}= \frac{(x-x_0)^{10}}{10!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^{10}}{10!} $$
 * }
 * }


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

$$\displaystyle R_{10}(x)_{max} = 2.4611 * 10^{-8} $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

(k)$$\displaystyle R_{n+1}(x)_{max}$$ for $$\displaystyle n=10 $$ ,$$\displaystyle x_0 = \frac{\pi}{4} $$ and $$\displaystyle x = \frac{\pi}{2} $$


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


 * $$ \displaystyle R_{11}(x)_{max}= \frac{(x-x_0)^{11}}{11!}  $$
 * }
 * }
 * }


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

$$ \displaystyle = \frac{(\frac{\pi}{2}-\frac{\pi}{4})^{11}}{11!} $$
 * }
 * }


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

$$\displaystyle R_{11}(x)_{max} = 1.7572 * 10^{-9} $$
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style= |
 * }
 * }

--Subramanian Annamalai 23:58, 26 January 2010 (UTC)

= (10)Kessler's code =

Problem Statement
1. Run Kessler's code to reproduce the table of constants and the values of polynomials at t=1 obtained by Kessler. 2. Explain Kessler's code by giving comments for every line. 3. Obtain $$ \displaystyle (p_2,p_3) \; (p_4,p_5) \; (p_6,p_7)$$ by understanding Kessler's code line by line.

Ref: Lecture Notes [[media:Egm6341.s10.mtg30.djvu|p.30-2]] and [[media:Egm6341.s10.mtg37.djvu|p.37-1]]

Ref: Trapezoidal rule error

Solution
Part I : Generation of the Table To generate the table given in Kessler's paper, the following modifications are to be carried out.

1. The first half of the code is the main code. Give that a name called kessler.m

2. The second half of the code is a subroutine with the name fracsum. This should not be part of the file kessler.m   We need to create a new file called fracsum.m in the same folder that contains the file kessler.m

3. Set n=8. This is to ensure that we get the constants $$ c_1 \; through \; c_{17} $$ and polynomials $$ p_2(1) \; through\; p_{16}(1) $$.

4. The most important part is that the subroutine fracsum should end with the line, dsum=dsum/div;

5. The following lines have been appended to kessler.m to generate the table.

Result

Part II: Line by Line Explanation of Kessler's MATLAB Code - Adding Comments
 * {| style="width:100%" border="0" align="left"


 * }
 * }
 * }
 * }

Part III : Generating $$\displaystyle (p_2,p_3),(p_4,p_5),(p_6,p_7)$$
 * {| style="width:100%" border="0" align="left"


 * Recall the following:
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle p_1(t) = c_1 t $$
 * $$\displaystyle (Eq. 1)
 * $$\displaystyle (Eq. 1)
 * }


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


 * $$\displaystyle p_2(t) = c_1 \frac{t^2}{2!} + c_3 $$
 * $$\displaystyle (Eq. 2) $$
 * }
 * }


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


 * $$\displaystyle p_3(t) = c_1 \frac{t^3}{3!} + c_3 t $$
 * $$\displaystyle (Eq. 3) $$
 * }
 * }


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


 * $$\displaystyle p_4(t) = c_1 \frac{t^4}{4!} + c_3 \frac{t^2}{2!} + c_5 $$
 * $$\displaystyle (Eq. 4) $$
 * }
 * }


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


 * $$\displaystyle p_5(t) = c_1 \frac{t^5}{5!} + c_3 \frac{t^3}{3!} + c_5 t $$
 * $$\displaystyle (Eq. 5) $$
 * }
 * }


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


 * $$\displaystyle p_6(t) = c_1 \frac{t^6}{6!} + c_3 \frac{t^4}{4!} + c_5 \frac{t^2}{2!} + c_7 $$
 * $$\displaystyle (Eq. 6) $$
 * }
 * }


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


 * $$\displaystyle p_7(t) = c_1 \frac{t^7}{7!} + c_3 \frac{t^5}{5!} + c_5 \frac{t^3}{3!} + c_7 t $$
 * $$\displaystyle (Eq. 7) $$
 * }
 * }


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

$$\displaystyle c_1, c_3, c_5 \;and\; c_7 $$ 
 * Hence we need to find out the constants,
 * Hence we need to find out the constants,
 * }
 * {| style="width:100%" border="0" align="left"

And then we need to have n=3 ,because,
 * So we start off with setting $$ c_1 = -1 $$
 * So we start off with setting $$ c_1 = -1 $$
 * }


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


 * $$\displaystyle n=1 \;will\; yield\; c_3 $$
 * }
 * }


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


 * $$\displaystyle n=2 \;will\; yield\; c_5 $$
 * }
 * }


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


 * $$\displaystyle n=3 \;will\; yield\; c_7 $$
 * }
 * }




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

$$\displaystyle f=1 \,\,\, g=2$$ $$\displaystyle n=3; $$
 * $$\displaystyle c_1 = -1 $$
 * $$\displaystyle c_1 = -1 $$
 * }


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


 * Consider the first iteration: i.e, k=1
 * }
 * }


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

f= 1*2*3 =6
 * $$ \displaystyle f=f.*g.*(g+1) $$ yields
 * $$ \displaystyle f=f.*g.*(g+1) $$ yields
 * }


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

$$\displaystyle f=6 $$ 
 * Hence,
 * 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 [newcn,newcd]=fracsum(-1*cn,cd.*f);$$
 * }
 * }


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

fracsum(-1*1, 1*6) i.e, fracsum(-1,6)
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * }


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

$$\displaystyle fracsum(-1,6) $$ 
 * Hence,we have
 * 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 div=gcd(round(n),round(d))$$
 * Now looking into the fracsum(n,d) function,
 * Now looking into the fracsum(n,d) function,
 * }


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

because, round(-1) = -1 round(6) = 6 and hence, gcd(-1,6) = 1.
 * will yield div = 1.
 * will yield div = 1.
 * }




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

$$n=round(n./div);$$ will give n=1 becasue round(1/1) =1
 * Now,
 * Now,
 * }

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

will give d=6 becasue round(6/1) =6
 * $$\displaystyle d=round(d./div);$$
 * $$\displaystyle d=round(d./div);$$
 * }


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

$$\displaystyle n=1\; and\; d=6 $$
 * Thus,
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }


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

$$\displaystyle for k=1:length(d) $$ $$\displaystyle dsum=lcm(dsum,d(k)); $$ $$\displaystyle end $$
 * $$\displaystyle dsum=1; $$
 * $$\displaystyle dsum=1; $$
 * }
 * }


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

and lcm (1,6) = 6, we have, dsum =6.
 * Since length(d) = 1
 * Since length(d) = 1
 * }
 * }


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

$$\displaystyle dsum = 6 $$
 * Thus,
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }


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

$$ \displaystyle div=gcd(round(nsum),round(dsum)); $$
 * $$ \displaystyle nsum=dsum*sum(n./d);$$
 * $$ \displaystyle nsum=dsum*sum(n./d);$$
 * }
 * }

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

and <br\>
 * nsum = 6* sum(1/6) = 1
 * nsum = 6* sum(1/6) = 1
 * }

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

since, round(nsum) = round(1) = 1 round(dsum) = round(6) = 6 gcd(1,6) =1
 * div = 1
 * div = 1
 * }

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

$$ \displaystyle dsum=dsum/div; $$
 * $$ \displaystyle nsum=nsum/div; $$
 * $$ \displaystyle nsum=nsum/div; $$
 * }

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

dsum = 6
 * nsum = 1
 * nsum = 1
 * }


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

$$\displaystyle [newcn \; newcd] = [1 \; 6] $$
 * Now going back,
 * Now going back,
 * }


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

$$\displaystyle \therefore c_3 = \frac{1}{6} $$ <br\>
 * Thus,
 * 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 cn=[cn;newcn]; cd=[cd;newcd] $$ $$\displaystyle f=[f;1]; $$
 * Next, we have,
 * Next, we have,
 * }


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

cn = [-1;1]; cd=[1;6]
 * Hence,
 * Hence,
 * }


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

So, f=[6;1]
 * and,
 * and,
 * }

This is followed by,


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

which means, g = [2+2, 2] = [4;2]
 * $$\displaystyle g=[2+g(1);g] $$ ;
 * $$\displaystyle g=[2+g(1);g] $$ ;
 * }

Now consider the second iteration - i.e, k=2


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


 * Consider the second iteration: i.e, k=2
 * }
 * }


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

f= (6*4*5; 1*2*3)
 * $$ \displaystyle f=f.*g.*(g+1) $$ yields
 * $$ \displaystyle f=f.*g.*(g+1) $$ yields
 * }


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

$$\displaystyle f=(120;6) $$ <br\>
 * Hence,
 * 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 [newcn,newcd]=fracsum(-1*cn,cd.*f);$$
 * }
 * }


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

fracsum(-1*-1, 1*120) i.e, fracsum(1,120)
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * }

and,


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

fracsum(-1*1, 6*6) i.e, fracsum(-1,36)
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * $$ \displaystyle fracsum(-1*cn,cd.*f) $$ yields
 * }


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

$$\displaystyle fracsum(1,120)\; and\; fracsum(-1,36) $$ <br\>
 * Hence,we have
 * 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 div=gcd(round(n),round(d))$$
 * Now looking into the fracsum(1,120) function,
 * Now looking into the fracsum(1,120) function,
 * }


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

because, round(1) = 1 round(120) = 120 and hence, gcd(1,120) = 1.
 * will yield div = 1.
 * will yield div = 1.
 * }

<br\>


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

$$n=round(n./div);$$ will give n=1 becasue round(1/1) =1
 * Now,
 * Now,
 * }

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

will give d=120 becasue round(36/1) =120
 * $$\displaystyle d=round(d./div);$$
 * $$\displaystyle d=round(d./div);$$
 * }and,

<br\>


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

$$\displaystyle div=gcd(round(n),round(d))$$
 * Now looking into the fracsum(-1,36) function,
 * Now looking into the fracsum(-1,36) function,
 * }


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

because, round(-1) = -1 round(36) = 36 and hence, gcd(-1,36) = 1.
 * will yield div = 1.
 * will yield div = 1.
 * }

<br\>


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

$$n=round(n./div);$$ will give n=-1 becasue round(-1/1) =-1
 * Now,
 * Now,
 * }

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

will give d=6 becasue round(36/1) =36
 * $$\displaystyle d=round(d./div);$$
 * $$\displaystyle d=round(d./div);$$
 * }


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

$$\displaystyle n=[1;-1]\; and\; d=[120;36] $$
 * Thus,
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style="width:35%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }


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

$$\displaystyle for k=1:length(d) $$ $$\displaystyle dsum=lcm(dsum,d(k)); $$ $$\displaystyle end $$
 * $$\displaystyle dsum=1; $$
 * $$\displaystyle dsum=1; $$
 * }
 * }


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

and For d(1), dsum = lcm (1,120) = 120, and once again for d(2), dsum = lcm (120,36) = 360 Finally we have, dsum = 360.
 * Since length(d) = 2
 * Since length(d) = 2
 * }
 * }


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

$$\displaystyle dsum = 360$$
 * Thus,
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style="width:15%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }


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

$$ \displaystyle div=gcd(round(nsum),round(dsum)); $$
 * $$ \displaystyle nsum=dsum*sum(n./d);$$
 * $$ \displaystyle nsum=dsum*sum(n./d);$$
 * }
 * }

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

and <br\>
 * nsum = 360* sum(1/120 - 1/36) = -7
 * nsum = 360* sum(1/120 - 1/36) = -7
 * }

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

since, round(nsum) = round(-7) = -7 round(dsum) = round(360) = 360 gcd(-7,360) =1
 * div = 1
 * div = 1
 * }

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

$$ \displaystyle dsum=dsum/div; $$
 * $$ \displaystyle nsum=nsum/div; $$
 * $$ \displaystyle nsum=nsum/div; $$
 * }

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

dsum = 360
 * nsum = -7
 * nsum = -7
 * }


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

$$\displaystyle [newcn\; newcd] = [-7 \;360] $$
 * Now going back,
 * Now going back,
 * }


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

$$\displaystyle \therefore c_5 = -\frac{7}{360} $$ <br\>
 * Thus,
 * 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 cn=[cn;newcn]; cd=[cd;newcd] $$ $$\displaystyle f=[f;1]; $$
 * Next, we have,
 * Next, we have,
 * }


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

cn = [-1;1;7]; cd=[1;6;360]
 * Hence,
 * Hence,
 * }


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

So, f=[120;6;1]
 * and,
 * and,
 * }

This is followed by,


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

which means, g = [2+4;4; 2] = [6;4;2]
 * $$\displaystyle g=[2+g(1);g] $$ ;
 * $$\displaystyle g=[2+g(1);g] $$ ;
 * }

<br\>


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

we will obtain,
 * Again following the same procedure for Iteration 3, i.e for k=3
 * Again following the same procedure for Iteration 3, i.e for k=3
 * }


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

$$\displaystyle \therefore c_7 = \frac{31}{15120} $$
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style="width:10%; padding:10px; border:2px solid #8888aa" |
 * style = |
 * }
 * }

<br\> <br\>


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


 * On substituting, the values of
 * }
 * }


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

in (Eq.1) through (Eq.7) we obtain,
 * $$\displaystyle c_1\;c_3\;c_5\;and\;c_7$$
 * $$\displaystyle c_1\;c_3\;c_5\;and\;c_7$$
 * }


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


 * $$\displaystyle p_1(t) = - t $$
 * }
 * }


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


 * $$\displaystyle p_2(t) = - \frac{t^2}{2!} + \frac{1}{6} $$
 * }
 * }


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


 * $$\displaystyle p_3(t) = - \frac{t^3}{3!} +\frac{t}{6}$$
 * }
 * }


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


 * $$\displaystyle p_4(t) = - \frac{t^4}{4!} + \frac{t^2}{12} -\frac{7}{360} $$
 * }
 * }


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


 * $$\displaystyle p_5(t) = - \frac{t^5}{5!} + \frac{t^3}{36} -\frac{7t}{360} $$
 * }
 * }


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


 * $$\displaystyle p_6(t) = - \frac{t^6}{6!} + \frac{t^4}{144} - \frac{7 t^2}{720} + \frac{31}{15120}$$
 * }
 * }


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

<br\>
 * $$\displaystyle p_7(t) = - \frac{t^7}{7!} + \frac{t^5}{720} - \frac{7 t^3}{2160} + \frac{31t}{15120} $$
 * }
 * }